From 543d22ebe9105f391bb90c8da23e814bc8f3369f Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Fri, 2 Nov 2012 06:52:36 +0000 Subject: Fix network RPC API backwards compat Commit d96102b6 bumped the RPC API version, but didn't handle backwards compatibility correctly. We need to retain support for the old 1.1 clients passing the original set of kwargs - we can't rename kwargs, nor can we make new kwargs required. Change-Id: I083e0fa156e9d30fa51a500ed3d5a8ebb7c8eac8 --- nova/network/manager.py | 30 ++++++++++++++++++++---------- nova/tests/network/test_manager.py | 26 ++++++++++++++++---------- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/nova/network/manager.py b/nova/network/manager.py index a944ebd40..9fbdec6ee 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -663,11 +663,13 @@ class FloatingIP(object): return False if floating_ip.get('fixed_ip_id') else True @wrap_check_policy - def migrate_instance_start(self, context, instance_uuid, rxtx_factor, - project_id, source, dest, floating_addresses): + def migrate_instance_start(self, context, instance_uuid, + floating_addresses, + rxtx_factor=None, project_id=None, + source=None, dest=None): # We only care if floating_addresses are provided and we're # switching hosts - if not floating_addresses or source == dest: + if not floating_addresses or (source and source == dest): return LOG.info(_("Starting migration network for instance" @@ -696,11 +698,15 @@ class FloatingIP(object): {'host': None}) @wrap_check_policy - def migrate_instance_finish(self, context, instance_uuid, rxtx_factor, - project_id, source, dest, floating_addresses): + def migrate_instance_finish(self, context, instance_uuid, + floating_addresses, host=None, + rxtx_factor=None, project_id=None, + source=None, dest=None): # We only care if floating_addresses are provided and we're # switching hosts - if not floating_addresses or source == dest: + if host and not dest: + dest = host + if not floating_addresses or (source and source == dest): return LOG.info(_("Finishing migration network for instance" @@ -1954,12 +1960,16 @@ class FlatManager(NetworkManager): """Returns the floating IPs associated with a fixed_address""" return [] - def migrate_instance_start(self, context, instance_uuid, rxtx_factor, - project_id, source, dest, floating_addresses): + def migrate_instance_start(self, context, instance_uuid, + floating_addresses, + rxtx_factor=None, project_id=None, + source=None, dest=None): pass - def migrate_instance_finish(self, context, instance_uuid, rxtx_factor, - project_id, source, dest, floating_addresses): + def migrate_instance_finish(self, context, instance_uuid, + floating_addresses, host=None, + rxtx_factor=None, project_id=None, + source=None, dest=None): pass diff --git a/nova/tests/network/test_manager.py b/nova/tests/network/test_manager.py index 77fccd904..cc67eb08a 100644 --- a/nova/tests/network/test_manager.py +++ b/nova/tests/network/test_manager.py @@ -1665,11 +1665,14 @@ class FloatingIPTestCase(test.TestCase): self.stubs.Set(self.network.l3driver, 'remove_floating_ip', fake_remove_floating_ip) self.mox.ReplayAll() - floating_ip_addresses = ['172.24.4.23', '172.24.4.24', '172.24.4.25'] - self.network.migrate_instance_start(self.context, FAKEUUID, - 3, self.project_id, - 'fake_source', 'fake_dest', - floating_ip_addresses) + addresses = ['172.24.4.23', '172.24.4.24', '172.24.4.25'] + self.network.migrate_instance_start(self.context, + instance_uuid=FAKEUUID, + floating_addresses=addresses, + rxtx_factor=3, + project_id=self.project_id, + source='fake_source', + dest='fake_dest') self.assertEqual(called['count'], 2) @@ -1703,11 +1706,14 @@ class FloatingIPTestCase(test.TestCase): self.stubs.Set(self.network.l3driver, 'add_floating_ip', fake_add_floating_ip) self.mox.ReplayAll() - floating_ip_addresses = ['172.24.4.23', '172.24.4.24', '172.24.4.25'] - self.network.migrate_instance_finish(self.context, FAKEUUID, - 3, self.project_id, - 'fake_source', 'fake_dest', - floating_ip_addresses) + addresses = ['172.24.4.23', '172.24.4.24', '172.24.4.25'] + self.network.migrate_instance_finish(self.context, + instance_uuid=FAKEUUID, + floating_addresses=addresses, + host='fake_dest', + rxtx_factor=3, + project_id=self.project_id, + source='fake_source') self.assertEqual(called['count'], 2) -- cgit