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
cd1b2bc0
authored
Sep 26, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: move Instance.migrate_vm to MigrateOperation
parent
bd5649a8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
11 deletions
+11
-11
circle/vm/models/instance.py
+0
-8
circle/vm/operations.py
+11
-3
No files found.
circle/vm/models/instance.py
View file @
cd1b2bc0
...
...
@@ -759,14 +759,6 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
for
net
in
self
.
interface_set
.
all
():
net
.
shutdown
()
def
migrate_vm
(
self
,
to_node
,
timeout
=
120
):
queue_name
=
self
.
get_remote_queue_name
(
'vm'
,
'slow'
)
return
vm_tasks
.
migrate
.
apply_async
(
args
=
[
self
.
vm_name
,
to_node
.
host
.
hostname
,
True
],
queue
=
queue_name
)
.
get
(
timeout
=
timeout
)
def
allocate_node
(
self
):
if
self
.
node
is
None
:
self
.
node
=
self
.
select_node
()
...
...
circle/vm/operations.py
View file @
cd1b2bc0
...
...
@@ -462,7 +462,7 @@ class DestroyOperation(InstanceOperation):
@register_operation
class
MigrateOperation
(
InstanceOperation
):
class
MigrateOperation
(
Remote
InstanceOperation
):
id
=
'migrate'
name
=
_
(
"migrate"
)
description
=
_
(
"Move virtual machine to an other worker node with a few "
...
...
@@ -471,6 +471,14 @@ class MigrateOperation(InstanceOperation):
superuser_required
=
True
accept_states
=
(
'RUNNING'
,
)
async_queue
=
"localhost.man.slow"
task
=
vm_tasks
.
migrate
remote_queue
=
(
"vm"
,
"slow"
)
timeout
=
600
def
_get_remote_args
(
self
,
to_node
,
**
kwargs
):
return
(
super
(
MigrateOperation
,
self
)
.
_get_remote_args
(
**
kwargs
)
+
[
to_node
.
host
.
hostname
,
True
])
# TODO handle non-live migration
def
rollback
(
self
,
activity
):
with
activity
.
sub_activity
(
...
...
@@ -478,7 +486,7 @@ class MigrateOperation(InstanceOperation):
"redeploy network (rollback)"
)):
self
.
instance
.
deploy_net
()
def
_operation
(
self
,
activity
,
to_node
=
None
,
timeout
=
120
):
def
_operation
(
self
,
activity
,
to_node
=
None
):
if
not
to_node
:
with
activity
.
sub_activity
(
'scheduling'
,
readable_name
=
ugettext_noop
(
...
...
@@ -490,7 +498,7 @@ class MigrateOperation(InstanceOperation):
with
activity
.
sub_activity
(
'migrate_vm'
,
readable_name
=
create_readable
(
ugettext_noop
(
"migrate to
%(node)
s"
),
node
=
to_node
)):
s
elf
.
instance
.
migrate_vm
(
to_node
=
to_node
,
timeout
=
timeout
)
s
uper
(
MigrateOperation
,
self
)
.
_operation
(
to_node
=
to_node
)
except
Exception
as
e
:
if
hasattr
(
e
,
'libvirtError'
):
self
.
rollback
(
activity
)
...
...
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