summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
Diffstat (limited to 'nova')
-rw-r--r--nova/compute/manager.py15
-rw-r--r--nova/compute/rpcapi.py7
-rw-r--r--nova/tests/compute/test_compute.py8
-rw-r--r--nova/tests/compute/test_rpcapi.py5
4 files changed, 21 insertions, 14 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 339dbcb5f..1a423a3c8 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -297,7 +297,7 @@ def _get_additional_capabilities():
class ComputeManager(manager.SchedulerDependentManager):
"""Manages the running instances from creation to destruction."""
- RPC_API_VERSION = '1.10'
+ RPC_API_VERSION = '1.11'
def __init__(self, compute_driver=None, *args, **kwargs):
"""Load configuration options and connect to the hypervisor."""
@@ -2119,19 +2119,22 @@ class ComputeManager(manager.SchedulerDependentManager):
dest_check_data)
@exception.wrap_exception(notifier=notifier, publisher_id=publisher_id())
- def check_can_live_migrate_source(self, ctxt, instance_id,
- dest_check_data):
+ def check_can_live_migrate_source(self, ctxt, dest_check_data,
+ instance_id=None, instance=None):
"""Check if it is possible to execute live migration.
This checks if the live migration can succeed, based on the
results from check_can_live_migrate_destination.
:param context: security context
- :param instance_id: nova.db.sqlalchemy.models.Instance.Id
+ :param instance: dict of instance data
+ :param instance_id: (deprecated and only supplied if no instance passed
+ in) nova.db.sqlalchemy.models.Instance.Id
:param dest_check_data: result of check_can_live_migrate_destination
"""
- instance_ref = self.db.instance_get(ctxt, instance_id)
- self.driver.check_can_live_migrate_source(ctxt, instance_ref,
+ if not instance:
+ instance = self.db.instance_get(ctxt, instance_id)
+ self.driver.check_can_live_migrate_source(ctxt, instance,
dest_check_data)
def pre_live_migration(self, context, instance_id,
diff --git a/nova/compute/rpcapi.py b/nova/compute/rpcapi.py
index 89a9e9e5f..9644781f4 100644
--- a/nova/compute/rpcapi.py
+++ b/nova/compute/rpcapi.py
@@ -70,6 +70,8 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
1.9 - Remove instance_uuid, add instance argument to attach_volume()
1.10 - Remove instance_id, add instance argument to
check_can_live_migrate_destination()
+ 1.11 - Remove instance_id, add instance argument to
+ check_can_live_migrate_source()
'''
BASE_RPC_API_VERSION = '1.0'
@@ -118,11 +120,12 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
version='1.10')
def check_can_live_migrate_source(self, ctxt, instance, dest_check_data):
+ instance_p = jsonutils.to_primitive(instance)
self.call(ctxt, self.make_msg('check_can_live_migrate_source',
- instance_id=instance['id'],
+ instance=instance_p,
dest_check_data=dest_check_data),
topic=_compute_topic(self.topic, ctxt, None, instance),
- version='1.2')
+ version='1.11')
def check_shared_storage_test_file(self, ctxt, filename, host):
raise rpc_common.RPCException(message=_('Deprecated from version 1.2'))
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index e2c736c54..6ccf2e312 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -1404,7 +1404,8 @@ class ComputeTestCase(BaseTestCase):
def test_check_can_live_migrate_source_works_correctly(self):
"""Confirm check_can_live_migrate_source works on positive path"""
context = self.context.elevated()
- inst_ref = self._create_fake_instance({'host': 'fake_host_2'})
+ inst_ref = jsonutils.to_primitive(self._create_fake_instance(
+ {'host': 'fake_host_2'}))
inst_id = inst_ref["id"]
dest = "fake_host_1"
@@ -1413,14 +1414,13 @@ class ComputeTestCase(BaseTestCase):
'check_can_live_migrate_source')
dest_check_data = {"test": "data"}
- db.instance_get(context, inst_id).AndReturn(inst_ref)
self.compute.driver.check_can_live_migrate_source(context,
inst_ref,
dest_check_data)
self.mox.ReplayAll()
- self.compute.check_can_live_migrate_source(context, inst_id,
- dest_check_data)
+ self.compute.check_can_live_migrate_source(context,
+ dest_check_data=dest_check_data, instance=inst_ref)
def test_check_can_live_migrate_destination_works_correctly(self):
"""Confirm check_can_live_migrate_destination works on positive path"""
diff --git a/nova/tests/compute/test_rpcapi.py b/nova/tests/compute/test_rpcapi.py
index 6d9e32fc7..9be465ca9 100644
--- a/nova/tests/compute/test_rpcapi.py
+++ b/nova/tests/compute/test_rpcapi.py
@@ -50,7 +50,8 @@ class ComputeRpcAPITestCase(test.TestCase):
methods_with_instance = [
'add_fixed_ip_to_instance', 'attach_volume',
- 'check_can_live_migrate_destination', 'get_console_output',
+ 'check_can_live_migrate_destination',
+ 'check_can_live_migrate_source', 'get_console_output',
'pause_instance', 'reboot_instance', 'suspend_instance',
'unpause_instance'
]
@@ -139,7 +140,7 @@ class ComputeRpcAPITestCase(test.TestCase):
def test_check_can_live_migrate_source(self):
self._test_compute_api('check_can_live_migrate_source', 'call',
- version='1.2', instance=self.fake_instance,
+ version='1.11', instance=self.fake_instance,
dest_check_data={"test": "data"})
def test_confirm_resize_cast(self):