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
71c7bedb
authored
Sep 26, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: move Instance.wake_up_vm to WakeUpVmOperation
parent
191641ad
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
14 deletions
+17
-14
circle/dashboard/tests/test_views.py
+2
-2
circle/vm/models/instance.py
+0
-7
circle/vm/operations.py
+15
-5
No files found.
circle/dashboard/tests/test_views.py
View file @
71c7bedb
...
...
@@ -512,20 +512,20 @@ class VmDetailTest(LoginMixin, TestCase):
self
.
login
(
c
,
"user2"
)
with
patch
.
object
(
Instance
,
'select_node'
,
return_value
=
None
),
\
patch
.
object
(
WakeUpOperation
,
'async'
)
as
new_wake_up
,
\
patch
(
'vm.tasks.vm_tasks.wake_up.apply_async'
)
as
wuaa
,
\
patch
.
object
(
Instance
.
WrongStateError
,
'send_message'
)
as
wro
:
inst
=
Instance
.
objects
.
get
(
pk
=
1
)
new_wake_up
.
side_effect
=
inst
.
wake_up
inst
.
_wake_up_vm
=
Mock
()
inst
.
get_remote_queue_name
=
Mock
(
return_value
=
'test'
)
inst
.
status
=
'SUSPENDED'
inst
.
set_level
(
self
.
u2
,
'owner'
)
with
patch
(
'dashboard.views.messages'
)
as
msg
:
response
=
c
.
post
(
"/dashboard/vm/1/op/wake_up/"
)
assert
not
msg
.
error
.
called
assert
inst
.
_wake_up_vm
.
called
self
.
assertEqual
(
response
.
status_code
,
302
)
self
.
assertEqual
(
inst
.
status
,
'RUNNING'
)
assert
new_wake_up
.
called
assert
wuaa
.
called
assert
not
wro
.
called
def
test_unpermitted_wake_up
(
self
):
...
...
circle/vm/models/instance.py
View file @
71c7bedb
...
...
@@ -792,13 +792,6 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
queue
=
queue_name
)
.
get
(
timeout
=
timeout
)
def
wake_up_vm
(
self
,
timeout
=
60
):
queue_name
=
self
.
get_remote_queue_name
(
'vm'
,
'slow'
)
return
vm_tasks
.
wake_up
.
apply_async
(
args
=
[
self
.
vm_name
,
self
.
mem_dump
[
'path'
]],
queue
=
queue_name
)
.
get
(
timeout
=
timeout
)
def
delete_mem_dump
(
self
,
timeout
=
15
):
queue_name
=
self
.
mem_dump
[
'datastore'
]
.
get_remote_queue_name
(
'storage'
,
'fast'
)
...
...
circle/vm/operations.py
View file @
71c7bedb
...
...
@@ -771,16 +771,13 @@ class WakeUpOperation(InstanceOperation):
else
:
activity
.
resultant_state
=
'ERROR'
def
_operation
(
self
,
activity
,
timeout
=
60
):
def
_operation
(
self
,
activity
):
# Schedule vm
self
.
instance
.
allocate_vnc_port
()
self
.
instance
.
allocate_node
()
# Resume vm
with
activity
.
sub_activity
(
'resuming'
,
readable_name
=
ugettext_noop
(
"resume virtual machine"
)):
self
.
instance
.
wake_up_vm
(
timeout
=
timeout
)
self
.
instance
.
_wake_up_vm
(
parent_activity
=
activity
)
# Estabilish network connection (vmdriver)
with
activity
.
sub_activity
(
...
...
@@ -793,6 +790,19 @@ class WakeUpOperation(InstanceOperation):
except
:
pass
@register_operation
class
WakeUpVmOperation
(
SubOperationMixin
,
RemoteInstanceOperation
):
id
=
"_wake_up_vm"
name
=
_
(
"resume virtual machine"
)
task
=
vm_tasks
.
wake_up
remote_queue
=
(
"vm"
,
"slow"
)
timeout
=
600
def
_get_remote_args
(
self
,
**
kwargs
):
return
(
super
(
WakeUpOperation
.
WakeUpVmOperation
,
self
)
.
_get_remote_args
(
**
kwargs
)
+
[
self
.
instance
.
mem_dump
[
'path'
]])
@register_operation
class
RenewOperation
(
InstanceOperation
):
...
...
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