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
Show 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):
tags
=
template
.
tags
.
all
()
if
tags
is
None
else
tags
# prepare parameters
kwargs
[
'template'
]
=
template
kwargs
[
'owner'
]
=
owner
kwargs
.
setdefault
(
'pw'
,
pwgen
())
ca
=
[
'name'
,
'description'
,
'num_cores'
,
'ram_size'
,
'max_ram_size'
,
'arch'
,
'priority'
,
'boot_menu'
,
'raw_data'
,
'lease'
,
'access_method'
]
for
attr
in
ca
:
kwargs
.
setdefault
(
attr
,
getattr
(
template
,
attr
))
common_fields
=
[
'name'
,
'description'
,
'num_cores'
,
'ram_size'
,
'max_ram_size'
,
'arch'
,
'priority'
,
'boot_menu'
,
'raw_data'
,
'lease'
,
'access_method'
]
params
=
dict
(
template
=
template
,
owner
=
owner
,
pw
=
pwgen
())
params
.
update
([(
f
,
getattr
(
template
,
f
))
for
f
in
common_fields
])
params
.
update
(
kwargs
)
# override defaults w/ user supplied values
# create instance and do additional setup
inst
=
cls
(
**
kwargs
)
inst
=
cls
(
**
params
)
# save instance
inst
.
clean
()
inst
.
save
()
# create related entities
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