Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b86972f5
authored
Mar 06, 2014
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
instance: added save_as_async and refactored save_as
parent
0e472d2f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
6 deletions
+13
-6
circle/vm/models/instance.py
+13
-6
No files found.
circle/vm/models/instance.py
View file @
b86972f5
...
...
@@ -968,7 +968,14 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
for
net
in
self
.
interface_set
.
all
():
net
.
deploy
()
def
save_as_template
(
self
,
name
,
**
kwargs
):
def
save_as_template_async
(
self
,
name
,
user
=
None
,
**
kwargs
):
return
local_tasks
.
save_as_template
.
apply_async
(
args
=
[
self
,
name
,
user
,
kwargs
],
queue
=
"localhost.man"
)
def
save_as_template
(
self
,
name
,
task_uuid
=
None
,
user
=
None
,
timeout
=
300
,
**
kwargs
):
with
instance_activity
(
code_suffix
=
"save_as_template"
,
instance
=
self
,
task_uuid
=
task_uuid
,
user
=
user
):
# prepare parameters
kwargs
.
setdefault
(
'name'
,
name
)
kwargs
.
setdefault
(
'description'
,
self
.
description
)
...
...
@@ -991,13 +998,13 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
except
Disk
.
WrongDiskTypeError
:
return
disk
# copy disks
disks
=
[
__try_save_disk
(
disk
)
for
disk
in
self
.
disks
.
all
()]
kwargs
.
setdefault
(
'disks'
,
disks
)
# create template and do additional setup
tmpl
=
InstanceTemplate
(
**
kwargs
)
tmpl
.
full_clean
()
logger
.
info
(
"Clean utani save"
)
tmpl
.
save
()
tmpl
.
disks
.
add
(
*
[
__try_save_disk
(
disk
)
for
disk
in
self
.
disks
.
all
()])
# save template
tmpl
.
save
()
try
:
...
...
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