summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/compute/manager.py11
-rw-r--r--nova/compute/rpcapi.py7
-rw-r--r--nova/tests/compute/test_compute.py15
-rw-r--r--nova/tests/compute/test_rpcapi.py7
4 files changed, 25 insertions, 15 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 09c82035f..e56d0c0c4 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -272,7 +272,7 @@ def _get_image_meta(context, image_ref):
class ComputeManager(manager.SchedulerDependentManager):
"""Manages the running instances from creation to destruction."""
- RPC_API_VERSION = '1.27'
+ RPC_API_VERSION = '1.28'
def __init__(self, compute_driver=None, *args, **kwargs):
"""Load configuration options and connect to the hypervisor."""
@@ -1676,7 +1676,7 @@ class ComputeManager(manager.SchedulerDependentManager):
network_id)
network_info = self._inject_network_info(context, instance=instance)
- self.reset_network(context, instance['uuid'])
+ self.reset_network(context, instance)
self._notify_about_instance_usage(
context, instance, "create_ip.end", network_info=network_info)
@@ -1701,7 +1701,7 @@ class ComputeManager(manager.SchedulerDependentManager):
network_info = self._inject_network_info(context,
instance=instance)
- self.reset_network(context, instance['uuid'])
+ self.reset_network(context, instance)
self._notify_about_instance_usage(
context, instance, "delete_ip.end", network_info=network_info)
@@ -1860,9 +1860,10 @@ class ComputeManager(manager.SchedulerDependentManager):
@checks_instance_lock
@wrap_instance_fault
- def reset_network(self, context, instance_uuid):
+ def reset_network(self, context, instance=None, instance_uuid=None):
"""Reset networking on the given instance."""
- instance = self.db.instance_get_by_uuid(context, instance_uuid)
+ if not instance:
+ instance = self.db.instance_get_by_uuid(context, instance_uuid)
LOG.debug(_('Reset network'), context=context, instance=instance)
self.driver.reset_network(instance)
diff --git a/nova/compute/rpcapi.py b/nova/compute/rpcapi.py
index d79cb0bba..f10efc19a 100644
--- a/nova/compute/rpcapi.py
+++ b/nova/compute/rpcapi.py
@@ -98,6 +98,7 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
remove_volume_connection()
1.27 - Remove instance_uuid, add instance argument to
rescue_instance()
+ 1.28 - Remove instance_uuid, add instance argument to reset_network()
'''
BASE_RPC_API_VERSION = '1.0'
@@ -354,9 +355,11 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
version='1.27')
def reset_network(self, ctxt, instance):
+ instance_p = jsonutils.to_primitive(instance)
self.cast(ctxt, self.make_msg('reset_network',
- instance_uuid=instance['uuid']),
- topic=_compute_topic(self.topic, ctxt, None, instance))
+ instance=instance_p),
+ topic=_compute_topic(self.topic, ctxt, None, instance),
+ version='1.28')
def resize_instance(self, ctxt, instance, migration_id, image):
topic = _compute_topic(self.topic, ctxt, None, instance)
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py
index de02a9d85..a6da5439c 100644
--- a/nova/tests/compute/test_compute.py
+++ b/nova/tests/compute/test_compute.py
@@ -707,19 +707,24 @@ class ComputeTestCase(BaseTestCase):
def test_reset_network(self):
"""Ensure we can reset networking on an instance"""
- called = {'reset': False}
+ called = {'count': 0}
def fake_driver_reset_network(self, instance):
- called['reset'] = True
+ called['count'] += 1
self.stubs.Set(nova.virt.fake.FakeDriver, 'reset_network',
fake_driver_reset_network)
- instance = self._create_fake_instance()
+ instance = jsonutils.to_primitive(self._create_fake_instance())
instance_uuid = instance['uuid']
self.compute.run_instance(self.context, instance_uuid)
- self.compute.reset_network(self.context, instance_uuid)
- self.assertTrue(called['reset'])
+
+ # Make sure it works with both an instance and instance_uuid
+ self.compute.reset_network(self.context, instance=instance)
+ self.compute.reset_network(self.context, instance_uuid=instance_uuid)
+
+ self.assertEqual(called['count'], 2)
+
self.compute.terminate_instance(self.context, instance_uuid)
def test_agent_update(self):
diff --git a/nova/tests/compute/test_rpcapi.py b/nova/tests/compute/test_rpcapi.py
index 27d379eed..0ab62d76a 100644
--- a/nova/tests/compute/test_rpcapi.py
+++ b/nova/tests/compute/test_rpcapi.py
@@ -58,8 +58,9 @@ class ComputeRpcAPITestCase(test.TestCase):
'post_live_migration_at_destination', 'power_off_instance',
'power_on_instance', 'pre_live_migration', 'reboot_instance',
'rebuild_instance', 'remove_fixed_ip_from_instance',
- 'remove_volume_connection', 'rescue_instance', 'start_instance',
- 'stop_instance', 'suspend_instance', 'unpause_instance'
+ 'remove_volume_connection', 'rescue_instance', 'reset_network',
+ 'start_instance', 'stop_instance', 'suspend_instance',
+ 'unpause_instance'
]
if 'rpcapi_class' in kwargs:
@@ -271,7 +272,7 @@ class ComputeRpcAPITestCase(test.TestCase):
def test_reset_network(self):
self._test_compute_api('reset_network', 'cast',
- instance=self.fake_instance)
+ instance=self.fake_instance, version='1.28')
def test_resize_instance(self):
self._test_compute_api('resize_instance', 'cast',