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
9b3849c1
authored
Nov 15, 2013
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: simplify method
parent
6456ad7f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
circle/vm/models.py
+10
-9
No files found.
circle/vm/models.py
View file @
9b3849c1
...
@@ -382,19 +382,20 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
...
@@ -382,19 +382,20 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
tags
=
template
.
tags
.
all
()
if
tags
is
None
else
tags
tags
=
template
.
tags
.
all
()
if
tags
is
None
else
tags
# prepare parameters
# prepare parameters
kwargs
[
'template'
]
=
template
common_fields
=
[
'name'
,
'description'
,
'num_cores'
,
'ram_size'
,
kwargs
[
'owner'
]
=
owner
'max_ram_size'
,
'arch'
,
'priority'
,
'boot_menu'
,
kwargs
.
setdefault
(
'pw'
,
pwgen
())
'raw_data'
,
'lease'
,
'access_method'
]
ca
=
[
'name'
,
'description'
,
'num_cores'
,
'ram_size'
,
'max_ram_size'
,
params
=
dict
(
template
=
template
,
owner
=
owner
,
pw
=
pwgen
())
'arch'
,
'priority'
,
'boot_menu'
,
'raw_data'
,
'lease'
,
params
.
update
([(
f
,
getattr
(
template
,
f
))
for
f
in
common_fields
])
'access_method'
]
params
.
update
(
kwargs
)
# override defaults w/ user supplied values
for
attr
in
ca
:
kwargs
.
setdefault
(
attr
,
getattr
(
template
,
attr
))
# create instance and do additional setup
# create instance and do additional setup
inst
=
cls
(
**
kwargs
)
inst
=
cls
(
**
params
)
# save instance
# save instance
inst
.
clean
()
inst
.
clean
()
inst
.
save
()
inst
.
save
()
# create related entities
# create related entities
inst
.
disks
.
add
(
*
[
disk
.
get_exclusive
()
for
disk
in
disks
])
inst
.
disks
.
add
(
*
[
disk
.
get_exclusive
()
for
disk
in
disks
])
...
...
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