From b93e851c0d90c17868a0e68a3b54e136bb5cd54d Mon Sep 17 00:00:00 2001 From: Stef T Date: Tue, 30 Oct 2012 12:02:50 -0400 Subject: Missing instance_uuid in floating_ip notifications * Addresses bug 1073212 Change-Id: I50327a9d7051d9ddb0a95a89b50037873011aff4 --- nova/network/manager.py | 17 ++++++++++++----- nova/tests/network/test_manager.py | 3 +++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/nova/network/manager.py b/nova/network/manager.py index cf7b6109d..fbac90c0a 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -526,7 +526,8 @@ class FloatingIP(object): if host == self.host: # i'm the correct host self._associate_floating_ip(context, floating_address, - fixed_address, interface) + fixed_address, interface, + fixed_ip['instance_uuid']) else: # send to correct host self.network_rpcapi._associate_floating_ip(context, @@ -535,7 +536,7 @@ class FloatingIP(object): return orig_instance_uuid def _associate_floating_ip(self, context, floating_address, fixed_address, - interface): + interface, instance_uuid): """Performs db and driver calls to associate floating ip & fixed ip""" # associate floating ip self.db.floating_ip_fixed_ip_associate(context, @@ -552,7 +553,9 @@ class FloatingIP(object): if "Cannot find device" in str(e): LOG.error(_('Interface %(interface)s not found'), locals()) raise exception.NoFloatingIpInterface(interface=interface) + payload = dict(project_id=context.project_id, + instance_id=instance_uuid, floating_ip=floating_address) notifier.notify(context, notifier.publisher_id("network"), @@ -605,13 +608,15 @@ class FloatingIP(object): if host == self.host: # i'm the correct host - self._disassociate_floating_ip(context, address, interface) + self._disassociate_floating_ip(context, address, interface, + fixed_ip['instance_uuid']) else: # send to correct host self.network_rpcapi._disassociate_floating_ip(context, address, interface, host) - def _disassociate_floating_ip(self, context, address, interface): + def _disassociate_floating_ip(self, context, address, interface, + instance_uuid): """Performs db and driver calls to disassociate floating ip""" # disassociate floating ip fixed_address = self.db.floating_ip_disassociate(context, address) @@ -619,7 +624,9 @@ class FloatingIP(object): if interface: # go go driver time self.l3driver.remove_floating_ip(address, fixed_address, interface) - payload = dict(project_id=context.project_id, floating_ip=address) + payload = dict(project_id=context.project_id, + instance_id=instance_uuid, + floating_ip=address) notifier.notify(context, notifier.publisher_id("network"), 'network.floating_ip.disassociate', diff --git a/nova/tests/network/test_manager.py b/nova/tests/network/test_manager.py index 698ce8f59..4ba0a6946 100644 --- a/nova/tests/network/test_manager.py +++ b/nova/tests/network/test_manager.py @@ -676,6 +676,7 @@ class VlanNetworkTestCase(test.TestCase): def fake5(*args, **kwargs): return {'address': '10.0.0.1', 'pool': 'nova', + 'instance_uuid': FAKEUUID, 'interface': 'eth0', 'network_id': 'blahblah'} @@ -706,6 +707,7 @@ class VlanNetworkTestCase(test.TestCase): ctxt, mox.IgnoreArg(), mox.IgnoreArg(), + mox.IgnoreArg(), mox.IgnoreArg()) self.stubs.Set(self.network, '_floating_ip_owned_by_project', fake1) @@ -822,6 +824,7 @@ class VlanNetworkTestCase(test.TestCase): def fake5(*args, **kwargs): return {'address': '10.0.0.1', 'pool': 'nova', + 'instance_uuid': FAKEUUID, 'interface': 'eth0', 'network_id': 'blahblah'} -- cgit