Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
95663de7
authored
Feb 20, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: fix Instance.sleep(), wake_up()
destroy networking on sleep, deploy networking on wake up
parent
c7bbf883
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
9 deletions
+29
-9
circle/vm/models/instance.py
+29
-9
No files found.
circle/vm/models/instance.py
View file @
95663de7
...
...
@@ -805,12 +805,22 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
with
instance_activity
(
code_suffix
=
'sleep'
,
instance
=
self
,
on_abort
=
__on_abort
,
on_commit
=
__on_commit
,
task_uuid
=
task_uuid
,
user
=
user
):
task_uuid
=
task_uuid
,
user
=
user
)
as
act
:
queue_name
=
self
.
get_remote_queue_name
(
'vm'
)
vm_tasks
.
sleep
.
apply_async
(
args
=
[
self
.
vm_name
,
self
.
mem_dump
[
'path'
]],
queue
=
queue_name
)
.
get
()
# Destroy networks
with
act
.
sub_activity
(
'destroying_net'
):
for
net
in
self
.
interface_set
.
all
():
net
.
destroy
(
delete_host
=
False
)
# Suspend vm
with
act
.
sub_activity
(
'suspending'
):
queue_name
=
self
.
get_remote_queue_name
(
'vm'
)
vm_tasks
.
sleep
.
apply_async
(
args
=
[
self
.
vm_name
,
self
.
mem_dump
[
'path'
]],
queue
=
queue_name
)
.
get
()
self
.
node
=
None
self
.
vnc_port
=
None
self
.
save
()
def
sleep_async
(
self
,
user
=
None
):
"""Execute sleep asynchronously.
...
...
@@ -830,12 +840,22 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
with
instance_activity
(
code_suffix
=
'wake_up'
,
instance
=
self
,
on_abort
=
__on_abort
,
on_commit
=
__on_commit
,
task_uuid
=
task_uuid
,
user
=
user
):
task_uuid
=
task_uuid
,
user
=
user
)
as
act
:
# Schedule vm
self
.
__schedule_vm
(
act
)
queue_name
=
self
.
get_remote_queue_name
(
'vm'
)
vm_tasks
.
wake_up
.
apply_async
(
args
=
[
self
.
vm_name
,
self
.
mem_dump
[
'path'
]],
queue
=
queue_name
)
.
get
()
# Resume vm
with
act
.
sub_activity
(
'resuming'
):
vm_tasks
.
wake_up
.
apply_async
(
args
=
[
self
.
vm_name
,
self
.
mem_dump
[
'path'
]],
queue
=
queue_name
)
.
get
()
# Estabilish network connection (vmdriver)
with
act
.
sub_activity
(
'deploying_net'
):
for
net
in
self
.
interface_set
.
all
():
net
.
deploy
()
def
wake_up_async
(
self
,
user
=
None
):
"""Execute wake_up asynchronously.
...
...
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