Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
82dccc14
authored
Feb 11, 2013
by
tarokkk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
one: add create vm by share
parent
a7bcad7d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
13 deletions
+25
-13
cloud/urls.py
+1
-0
one/templates/home.html
+11
-10
one/views.py
+9
-3
school/models.py
+4
-0
No files found.
cloud/urls.py
View file @
82dccc14
...
@@ -18,6 +18,7 @@ urlpatterns = patterns('',
...
@@ -18,6 +18,7 @@ urlpatterns = patterns('',
url
(
r'^login/$'
,
'school.views.login'
,
name
=
'login'
),
url
(
r'^login/$'
,
'school.views.login'
,
name
=
'login'
),
url
(
r'^logout/$'
,
'school.views.logout'
,
name
=
'logout'
),
url
(
r'^logout/$'
,
'school.views.logout'
,
name
=
'logout'
),
url
(
r'^vm/new/(?P<template>\d+)/$'
,
'one.views.vm_new'
,
name
=
'vm_new'
),
url
(
r'^vm/new/(?P<template>\d+)/$'
,
'one.views.vm_new'
,
name
=
'vm_new'
),
url
(
r'^vm/new/s(?P<share>\d+)/$'
,
'one.views.vm_new'
,
name
=
'vm_new'
),
url
(
r'^vm/show/(?P<iid>\d+)/$'
,
'one.views.vm_show'
,
name
=
'vm_show'
),
url
(
r'^vm/show/(?P<iid>\d+)/$'
,
'one.views.vm_show'
,
name
=
'vm_show'
),
url
(
r'^vm/delete/(?P<iid>\d+)/$'
,
'one.views.vm_delete'
,
name
=
'vm_delete'
),
url
(
r'^vm/delete/(?P<iid>\d+)/$'
,
'one.views.vm_delete'
,
name
=
'vm_delete'
),
url
(
r'^vm/stop/(?P<iid>\d+)/$'
,
'one.views.vm_stop'
,
name
=
'vm_stop'
),
url
(
r'^vm/stop/(?P<iid>\d+)/$'
,
'one.views.vm_stop'
,
name
=
'vm_stop'
),
...
...
one/templates/home.html
View file @
82dccc14
...
@@ -16,19 +16,19 @@
...
@@ -16,19 +16,19 @@
</div>
</div>
</li>
</li>
<li
id=
"new-wm"
style=
"display: none"
>
<li
id=
"new-wm"
style=
"display: none"
>
<h2>
{% trans "Available
templat
es" %}
</h2>
<h2>
{% trans "Available
shar
es" %}
</h2>
<p>
<p>
{% trans "Choose one of the following templates to launch." %}
{% trans "Choose one of the following
shared
templates to launch." %}
</p>
</p>
<div
class=
"container"
>
<div
class=
"container"
>
<ul
class=
"wm-list modal"
>
<ul
class=
"wm-list modal"
>
{% for
m in templat
es %}
{% for
s in shar
es %}
<li
class=
"wm"
>
<li
class=
"wm"
>
<div
class=
"summary"
>
<div
class=
"summary"
>
<div
class=
"quota"
>
<div
class=
"quota"
>
<div
class=
"used"
style=
"width: 40%"
></div>
<div
class=
"used"
style=
"width: 40%"
></div>
</div>
</div>
<div
class=
"name wm-on"
>
{{
m
.name}}
</div>
<div
class=
"name wm-on"
>
{{
s
.name}}
</div>
<div
class=
"status"
>
<div
class=
"status"
>
3/10
3/10
</div>
</div>
...
@@ -37,16 +37,17 @@
...
@@ -37,16 +37,17 @@
<div
class=
"details"
>
<div
class=
"details"
>
<div
class=
"details-container"
>
<div
class=
"details-container"
>
<ul>
<ul>
<li
class=
"os-{{m.os_type}}"
>
{% trans "System" %}:
<span
class=
"value"
>
{{m.system}}
</span><div
class=
"clear"
></div></li>
<li
class=
"os-{{s.template.os_type}}"
>
{% trans "System" %}:
<span
class=
"value"
>
{{s.template.system}}
</span><div
class=
"clear"
></div></li>
<li
class=
"type"
>
{% trans "Size" %}:
<span
class=
"value"
>
{{m.instance_type.name}}
</span></li>
<li
class=
"type"
>
{% trans "Size" %}:
<span
class=
"value"
>
{{s.template.instance_type.name}}
</span></li>
<li
class=
"share-type"
>
{% trans "Type" %}:
<span
class=
"value"
>
{{s.type }}
</span></li>
<li
class=
"memory"
>
{% trans "Memory" %}:
<li
class=
"memory"
>
{% trans "Memory" %}:
<span
class=
"value"
>
{% blocktrans with m=
m
.instance_type.RAM %}{{m}} MiB{% endblocktrans %}
</span></li>
<span
class=
"value"
>
{% blocktrans with m=
s.template
.instance_type.RAM %}{{m}} MiB{% endblocktrans %}
</span></li>
<li
class=
"cpu"
>
{% trans "CPU cores" %}:
<span
class=
"value"
>
{{
m
.instance_type.CPU}}
</span></li>
<li
class=
"cpu"
>
{% trans "CPU cores" %}:
<span
class=
"value"
>
{{
s.template
.instance_type.CPU}}
</span></li>
<li
class=
"description"
>
{% trans "Description" %}:
<span
class=
"value"
>
{{
m
.description}}
</span><div
class=
"clear"
></div></li>
<li
class=
"description"
>
{% trans "Description" %}:
<span
class=
"value"
>
{{
s
.description}}
</span><div
class=
"clear"
></div></li>
<li>
<li>
<span
class=
"value"
>
<span
class=
"value"
>
<form
method=
"POST"
action=
"/vm/new/
{{m
.pk}}/"
>
{% csrf_token %}
<form
method=
"POST"
action=
"/vm/new/
s{{s
.pk}}/"
>
{% csrf_token %}
<input
type=
"submit"
value=
"{% trans "
Launch
"
%}"
/>
<input
type=
"submit"
value=
"{% trans "
Launch
"
%}"
/>
</form>
</form>
</span>
</span>
...
...
one/views.py
View file @
82dccc14
...
@@ -74,6 +74,7 @@ def _list_instances(request):
...
@@ -74,6 +74,7 @@ def _list_instances(request):
@login_required
@login_required
def
home
(
request
):
def
home
(
request
):
return
render_to_response
(
"home.html"
,
RequestContext
(
request
,
{
return
render_to_response
(
"home.html"
,
RequestContext
(
request
,
{
'shares'
:
request
.
user
.
person_set
.
all
()[
0
]
.
get_shares
(),
'templates'
:
Template
.
objects
.
filter
(
state
=
'READY'
),
'templates'
:
Template
.
objects
.
filter
(
state
=
'READY'
),
'mytemplates'
:
Template
.
objects
.
filter
(
owner
=
request
.
user
),
'mytemplates'
:
Template
.
objects
.
filter
(
owner
=
request
.
user
),
'publictemplates'
:
Template
.
objects
.
filter
(
public
=
True
,
state
=
'READY'
),
'publictemplates'
:
Template
.
objects
.
filter
(
public
=
True
,
state
=
'READY'
),
...
@@ -191,13 +192,18 @@ def vm_saveas(request, vmid):
...
@@ -191,13 +192,18 @@ def vm_saveas(request, vmid):
@require_POST
@require_POST
@login_required
@login_required
def
vm_new
(
request
,
template
):
def
vm_new
(
request
,
template
=
None
,
share
=
None
):
base
=
get_object_or_404
(
Template
,
pk
=
template
)
base
=
None
if
template
:
base
=
get_object_or_404
(
Template
,
pk
=
template
)
else
:
share
=
get_object_or_404
(
Share
,
pk
=
share
)
base
=
share
.
template
if
"name"
in
request
.
POST
:
if
"name"
in
request
.
POST
:
if
base
.
owner
!=
request
.
user
and
not
base
.
public
and
not
request
.
user
.
is_superuser
:
if
base
.
owner
!=
request
.
user
and
not
base
.
public
and
not
request
.
user
.
is_superuser
:
raise
PermissionDenied
()
raise
PermissionDenied
()
name
=
request
.
POST
[
'name'
]
name
=
request
.
POST
[
'name'
]
t
=
Template
.
objects
.
create
(
name
=
name
,
disk
=
base
.
disk
,
instance_type_id
=
request
.
POST
[
'size'
],
network
=
base
.
network
,
owner
=
request
.
user
)
t
=
Template
.
objects
.
create
(
name
=
name
,
disk
=
base
.
disk
,
instance_type_id
=
request
.
POST
[
'size'
],
network
=
base
.
network
,
owner
=
request
.
user
,
share
=
share
)
t
.
access_type
=
base
.
access_type
t
.
access_type
=
base
.
access_type
t
.
description
=
request
.
POST
[
'description'
]
t
.
description
=
request
.
POST
[
'description'
]
t
.
system
=
base
.
system
t
.
system
=
base
.
system
...
...
school/models.py
View file @
82dccc14
...
@@ -5,6 +5,7 @@ from django.db.models.signals import post_save
...
@@ -5,6 +5,7 @@ from django.db.models.signals import post_save
from
django.core.exceptions
import
ValidationError
from
django.core.exceptions
import
ValidationError
from
datetime
import
datetime
from
datetime
import
datetime
from
django.conf
import
settings
from
django.conf
import
settings
import
one.models
LANGUAGE_CODE
=
settings
.
LANGUAGE_CODE
LANGUAGE_CODE
=
settings
.
LANGUAGE_CODE
...
@@ -28,6 +29,9 @@ class Person(models.Model):
...
@@ -28,6 +29,9 @@ class Person(models.Model):
choices
=
LANGUAGE_CHOICES
,
default
=
LANGUAGE_CODE
)
choices
=
LANGUAGE_CHOICES
,
default
=
LANGUAGE_CODE
)
code
=
models
.
CharField
(
_
(
'code'
),
max_length
=
30
,
unique
=
True
)
code
=
models
.
CharField
(
_
(
'code'
),
max_length
=
30
,
unique
=
True
)
def
get_shares
(
self
):
return
one
.
models
.
Share
.
objects
.
filter
(
group__in
=
self
.
course_groups
.
all
())
def
short_name
(
self
):
def
short_name
(
self
):
if
self
.
user
.
last_name
:
if
self
.
user
.
last_name
:
return
self
.
user
.
last_name
return
self
.
user
.
last_name
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment