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
d739baa2
authored
Apr 02, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: distiguish base vms and vms started from template
parent
3de47528
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
circle/dashboard/forms.py
+7
-9
circle/dashboard/views.py
+8
-0
No files found.
circle/dashboard/forms.py
View file @
d739baa2
...
@@ -450,18 +450,20 @@ class TemplateForm(forms.ModelForm):
...
@@ -450,18 +450,20 @@ class TemplateForm(forms.ModelForm):
networks
=
forms
.
ModelMultipleChoiceField
(
networks
=
forms
.
ModelMultipleChoiceField
(
queryset
=
VLANS
,
required
=
False
)
queryset
=
VLANS
,
required
=
False
)
system
=
forms
.
CharField
(
widget
=
forms
.
TextInput
)
system
=
forms
.
CharField
(
widget
=
forms
.
TextInput
)
parent_type
=
forms
.
CharField
(
required
=
False
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
parent
=
kwargs
.
pop
(
"parent"
,
None
)
self
.
parent
=
kwargs
.
pop
(
"parent"
,
None
)
self
.
user
=
kwargs
.
pop
(
"user"
,
None
)
self
.
user
=
kwargs
.
pop
(
"user"
,
None
)
super
(
TemplateForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
TemplateForm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
data
=
self
.
data
.
copy
()
data
=
self
.
data
.
copy
()
data
[
'owner'
]
=
self
.
user
.
pk
data
[
'owner'
]
=
self
.
user
.
pk
self
.
data
=
data
self
.
data
=
data
self
.
initial
[
'parent_type'
]
=
self
.
parent
if
parent
is
not
None
and
parent
.
isdigit
():
if
self
.
parent
is
not
None
and
self
.
parent
.
isdigit
():
template
=
get_object_or_404
(
InstanceTemplate
,
pk
=
parent
)
template
=
get_object_or_404
(
InstanceTemplate
,
pk
=
self
.
parent
)
parent
=
template
.
__dict__
parent
=
template
.
__dict__
fields
=
[
"system"
,
"name"
,
"num_cores"
,
"boot_menu"
,
"ram_size"
,
fields
=
[
"system"
,
"name"
,
"num_cores"
,
"boot_menu"
,
"ram_size"
,
"priority"
,
"access_method"
,
"raw_data"
,
"priority"
,
"access_method"
,
"raw_data"
,
...
@@ -475,7 +477,7 @@ class TemplateForm(forms.ModelForm):
...
@@ -475,7 +477,7 @@ class TemplateForm(forms.ModelForm):
else
:
else
:
self
.
for_networks
=
self
.
instance
self
.
for_networks
=
self
.
instance
if
self
.
instance
.
pk
or
parent
is
not
None
:
if
self
.
instance
.
pk
or
self
.
parent
is
not
None
:
n
=
self
.
for_networks
.
interface_set
.
values_list
(
"vlan"
,
flat
=
True
)
n
=
self
.
for_networks
.
interface_set
.
values_list
(
"vlan"
,
flat
=
True
)
self
.
initial
[
'networks'
]
=
n
self
.
initial
[
'networks'
]
=
n
...
@@ -501,16 +503,11 @@ class TemplateForm(forms.ModelForm):
...
@@ -501,16 +503,11 @@ class TemplateForm(forms.ModelForm):
def
save
(
self
,
commit
=
True
):
def
save
(
self
,
commit
=
True
):
data
=
self
.
cleaned_data
data
=
self
.
cleaned_data
self
.
instance
.
max_ram_size
=
data
.
get
(
'ram_size'
)
self
.
instance
.
max_ram_size
=
data
.
get
(
'ram_size'
)
is_new
=
self
.
instance
.
pk
is
None
instance
=
super
(
TemplateForm
,
self
)
.
save
(
commit
=
False
)
instance
=
super
(
TemplateForm
,
self
)
.
save
(
commit
=
False
)
if
commit
:
if
commit
:
instance
.
save
()
instance
.
save
()
if
is_new
:
self
.
instance
.
disks
=
InstanceTemplate
.
objects
.
get
(
pk
=
self
.
instance
.
parent
.
pk
)
.
disks
.
all
()
# create and/or delete InterfaceTemplates
# create and/or delete InterfaceTemplates
networks
=
InterfaceTemplate
.
objects
.
filter
(
networks
=
InterfaceTemplate
.
objects
.
filter
(
template
=
self
.
instance
)
.
values_list
(
"vlan"
,
flat
=
True
)
template
=
self
.
instance
)
.
values_list
(
"vlan"
,
flat
=
True
)
...
@@ -532,6 +529,7 @@ class TemplateForm(forms.ModelForm):
...
@@ -532,6 +529,7 @@ class TemplateForm(forms.ModelForm):
helper
=
FormHelper
()
helper
=
FormHelper
()
helper
.
layout
=
Layout
(
helper
.
layout
=
Layout
(
Field
(
"parent_type"
,
type
=
"hidden"
),
Field
(
"name"
),
Field
(
"name"
),
Fieldset
(
Fieldset
(
_
(
"Resource configuration"
),
_
(
"Resource configuration"
),
...
...
circle/dashboard/views.py
View file @
d739baa2
...
@@ -842,11 +842,19 @@ class TemplateCreate(SuccessMessageMixin, CreateView):
...
@@ -842,11 +842,19 @@ class TemplateCreate(SuccessMessageMixin, CreateView):
tags
=
post
.
pop
(
"tags"
)
tags
=
post
.
pop
(
"tags"
)
post
[
'pw'
]
=
User
.
objects
.
make_random_password
()
post
[
'pw'
]
=
User
.
objects
.
make_random_password
()
post
.
pop
(
"parent"
)
post
.
pop
(
"parent"
)
parent_type
=
post
.
pop
(
"parent_type"
)
post
[
'max_ram_size'
]
=
post
[
'ram_size'
]
post
[
'max_ram_size'
]
=
post
[
'ram_size'
]
inst
=
Instance
.
create
(
params
=
post
,
disks
=
[],
networks
=
networks
,
inst
=
Instance
.
create
(
params
=
post
,
disks
=
[],
networks
=
networks
,
tags
=
tags
,
req_traits
=
req_traits
)
tags
=
tags
,
req_traits
=
req_traits
)
messages
.
success
(
request
,
_
(
"The template has been created, "
messages
.
success
(
request
,
_
(
"The template has been created, "
"you can now add disks to it!"
))
"you can now add disks to it!"
))
# if it's not a base vm we need to add disks and deploy it
if
parent_type
!=
"base_vm"
:
template
=
get_object_or_404
(
InstanceTemplate
,
pk
=
parent_type
)
# TODO clone disks
inst
.
deploy_async
()
return
redirect
(
"
%
s#resources"
%
inst
.
get_absolute_url
())
return
redirect
(
"
%
s#resources"
%
inst
.
get_absolute_url
())
return
super
(
TemplateCreate
,
self
)
.
post
(
self
,
request
,
args
,
kwargs
)
return
super
(
TemplateCreate
,
self
)
.
post
(
self
,
request
,
args
,
kwargs
)
...
...
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