Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
19d0e9f2
authored
Mar 16, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: make Instance.migrate(to_node) optional
parent
52795ab4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
2 deletions
+35
-2
circle/vm/models/instance.py
+6
-1
circle/vm/tests/test_models.py
+29
-1
No files found.
circle/vm/models/instance.py
View file @
19d0e9f2
...
@@ -1068,10 +1068,15 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
...
@@ -1068,10 +1068,15 @@ class Instance(AclBase, VirtualMachineDescModel, TimeStampedModel):
return
local_tasks
.
migrate
.
apply_async
(
args
=
[
self
,
to_node
,
user
],
return
local_tasks
.
migrate
.
apply_async
(
args
=
[
self
,
to_node
,
user
],
queue
=
"localhost.man"
)
queue
=
"localhost.man"
)
def
migrate
(
self
,
to_node
,
user
=
None
,
task_uuid
=
None
,
timeout
=
120
):
def
migrate
(
self
,
to_node
=
None
,
user
=
None
,
task_uuid
=
None
,
timeout
=
120
):
"""Live migrate running vm to another node. """
"""Live migrate running vm to another node. """
with
instance_activity
(
code_suffix
=
'migrate'
,
instance
=
self
,
with
instance_activity
(
code_suffix
=
'migrate'
,
instance
=
self
,
task_uuid
=
task_uuid
,
user
=
user
)
as
act
:
task_uuid
=
task_uuid
,
user
=
user
)
as
act
:
if
not
to_node
:
with
act
.
sub_activity
(
'scheduling'
)
as
sa
:
to_node
=
self
.
select_node
()
sa
.
result
=
to_node
# Destroy networks
# Destroy networks
with
act
.
sub_activity
(
'destroying_net'
):
with
act
.
sub_activity
(
'destroying_net'
):
for
net
in
self
.
interface_set
.
all
():
for
net
in
self
.
interface_set
.
all
():
...
...
circle/vm/tests/test_models.py
View file @
19d0e9f2
from
django.test
import
TestCase
from
django.test
import
TestCase
from
mock
import
Mock
from
mock
import
Mock
,
MagicMock
,
patch
,
call
from
..models.common
import
(
from
..models.common
import
(
Lease
Lease
...
@@ -10,6 +10,7 @@ from ..models.instance import (
...
@@ -10,6 +10,7 @@ from ..models.instance import (
from
..models.network
import
(
from
..models.network
import
(
Interface
Interface
)
)
from
..models.node
import
Node
class
PortFinderTestCase
(
TestCase
):
class
PortFinderTestCase
(
TestCase
):
...
@@ -39,6 +40,33 @@ class InstanceTestCase(TestCase):
...
@@ -39,6 +40,33 @@ class InstanceTestCase(TestCase):
inst
=
Mock
(
state
=
'RUNNING'
)
inst
=
Mock
(
state
=
'RUNNING'
)
assert
Instance
.
is_running
.
getter
(
inst
)
assert
Instance
.
is_running
.
getter
(
inst
)
def
test_migrate_with_scheduling
(
self
):
inst
=
MagicMock
(
spec
=
Instance
)
inst
.
interface_set
.
all
.
return_value
=
[]
inst
.
node
=
MagicMock
(
spec
=
Node
)
with
patch
(
'vm.models.instance.instance_activity'
)
as
ia
,
\
patch
(
'vm.models.instance.vm_tasks.migrate'
)
as
migr
:
Instance
.
migrate
(
inst
)
migr
.
apply_async
.
assert_called
()
self
.
assertIn
(
call
()
.
__enter__
()
.
sub_activity
(
u'scheduling'
),
ia
.
mock_calls
)
inst
.
select_node
.
assert_called
()
def
test_migrate_wo_scheduling
(
self
):
inst
=
MagicMock
(
spec
=
Instance
)
inst
.
interface_set
.
all
.
return_value
=
[]
inst
.
node
=
MagicMock
(
spec
=
Node
)
with
patch
(
'vm.models.instance.instance_activity'
)
as
ia
,
\
patch
(
'vm.models.instance.vm_tasks.migrate'
)
as
migr
:
inst
.
select_node
.
side_effect
=
AssertionError
Instance
.
migrate
(
inst
,
inst
.
node
)
migr
.
apply_async
.
assert_called
()
self
.
assertNotIn
(
call
()
.
__enter__
()
.
sub_activity
(
u'scheduling'
),
ia
.
mock_calls
)
class
InterfaceTestCase
(
TestCase
):
class
InterfaceTestCase
(
TestCase
):
...
...
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