Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d4737b15
authored
Mar 04, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: add disks via URL in template edit
parent
5cbfba57
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
21 deletions
+25
-21
circle/dashboard/forms.py
+20
-18
circle/dashboard/urls.py
+1
-1
circle/dashboard/views.py
+4
-2
No files found.
circle/dashboard/forms.py
View file @
d4737b15
from
datetime
import
timedelta
import
uuid
from
django.contrib.auth.models
import
User
...
...
@@ -759,26 +758,29 @@ class DiskAddForm(forms.Form):
def
save
(
self
,
commit
=
True
):
data
=
self
.
cleaned_data
if
data
[
'size'
]:
d
=
Disk
(
name
=
data
[
'name'
],
filename
=
str
(
uuid
.
uuid4
()),
datastore
=
DataStore
.
objects
.
all
()[
0
],
type
=
"qcow2-norm"
,
size
=
data
[
'size'
],
dev_num
=
"a"
,
)
d
.
save
()
else
:
# TODO
d
=
None
if
self
.
is_template
:
vm_or_temp
=
InstanceTemplate
.
objects
.
get
(
pk
=
self
.
object_pk
)
inst
=
InstanceTemplate
.
objects
.
get
(
pk
=
self
.
object_pk
)
else
:
vm_or_temp
=
Instance
.
objects
.
get
(
pk
=
self
.
object_pk
)
inst
=
Instance
.
objects
.
get
(
pk
=
self
.
object_pk
)
vm_or_temp
.
disks
.
add
(
d
)
if
data
[
'size'
]:
kwargs
=
{
'name'
:
data
[
'name'
],
'type'
:
"qcow2-norm"
,
'datastore'
:
DataStore
.
objects
.
all
()[
0
],
'size'
:
data
[
'size'
],
'dev_num'
:
"a"
,
}
d
=
Disk
.
create_empty
(
instance
=
inst
,
user
=
None
,
**
kwargs
)
else
:
kwargs
=
{
'name'
:
data
[
'name'
],
'datastore'
:
DataStore
.
objects
.
all
()[
0
],
'dev_num'
:
"a"
,
}
Disk
.
create_from_url_async
(
data
[
'url'
],
instance
=
inst
,
user
=
None
,
**
kwargs
)
d
=
None
return
d
...
...
circle/dashboard/urls.py
View file @
d4737b15
...
...
@@ -9,7 +9,7 @@ from .views import (
FavouriteView
,
NodeStatus
,
GroupList
,
TemplateDelete
,
LeaseDelete
,
VmGraphView
,
TemplateAclUpdateView
,
GroupDetailView
,
GroupDelete
,
GroupAclUpdateView
,
GroupUserDelete
,
NotificationView
,
NodeGraphView
,
VmMigrateView
,
DiskAddVie
,
VmDetailVncTokenView
,
VmMigrateView
,
DiskAddVie
w
,
VmDetailVncTokenView
,
)
urlpatterns
=
patterns
(
...
...
circle/dashboard/views.py
View file @
d4737b15
...
...
@@ -744,11 +744,13 @@ class TemplateDetail(LoginRequiredMixin, SuccessMessageMixin, UpdateView):
return
super
(
TemplateDetail
,
self
)
.
get
(
request
,
*
args
,
**
kwargs
)
def
get_context_data
(
self
,
**
kwargs
):
obj
=
self
.
get_object
()
context
=
super
(
TemplateDetail
,
self
)
.
get_context_data
(
**
kwargs
)
context
[
'acl'
]
=
get_vm_acl_data
(
self
.
get_object
())
context
[
'acl'
]
=
get_vm_acl_data
(
obj
)
context
[
'disks'
]
=
obj
.
disks
.
all
()
context
[
'disk_add_form'
]
=
DiskAddForm
(
is_template
=
True
,
object_pk
=
self
.
get_object
()
.
pk
,
object_pk
=
obj
.
pk
,
prefix
=
"disk"
,
)
return
context
...
...
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