From 4a0210ebc87fe716aa2aa441bc48ee2908bb2a2a Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Thu, 19 Jun 2014 13:58:48 +0200 Subject: [PATCH] VMWare: don't notify on disassociate_floatingips() L3 agent notifications don't make sense for NSX VMWare plugin since there is no L3 agent in such setup, so disabling them here. Updated a unit test to check that notification is indeed not requested. Conflicts: neutron/tests/unit/vmware/test_nsx_plugin.py Change-Id: I9c7c32d02d466098d22df8f10448361c3d99174c Related-Bug: 1330955 (cherry picked from commit eafebec2d3f6d0bd0ecc6e6d7c4f1ae421a44dfe) --- neutron/plugins/vmware/plugins/base.py | 6 ++++- neutron/tests/unit/vmware/test_nsx_plugin.py | 27 ++++++++++++-------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/neutron/plugins/vmware/plugins/base.py b/neutron/plugins/vmware/plugins/base.py index 6e3000a93..22caf4750 100644 --- a/neutron/plugins/vmware/plugins/base.py +++ b/neutron/plugins/vmware/plugins/base.py @@ -2007,7 +2007,11 @@ class NsxPluginV2(addr_pair_db.AllowedAddressPairsMixin, except n_exc.NotFound: LOG.warning(_("Nat rules not found in nsx for port: %s"), id) - super(NsxPluginV2, self).disassociate_floatingips(context, port_id) + # NOTE(ihrachys): L3 agent notifications don't make sense for + # NSX VMWare plugin since there is no L3 agent in such setup, so + # disabling them here. + super(NsxPluginV2, self).disassociate_floatingips( + context, port_id, do_notify=False) def create_network_gateway(self, context, network_gateway): """Create a layer-2 network gateway. diff --git a/neutron/tests/unit/vmware/test_nsx_plugin.py b/neutron/tests/unit/vmware/test_nsx_plugin.py index fec1b2092..79e035315 100644 --- a/neutron/tests/unit/vmware/test_nsx_plugin.py +++ b/neutron/tests/unit/vmware/test_nsx_plugin.py @@ -943,17 +943,22 @@ class TestL3NatTestCase(L3NatTest, with self.port() as p: private_sub = {'subnet': {'id': p['port']['fixed_ips'][0]['subnet_id']}} - with self.floatingip_no_assoc(private_sub) as fip: - port_id = p['port']['id'] - body = self._update('floatingips', fip['floatingip']['id'], - {'floatingip': {'port_id': port_id}}) - self.assertEqual(body['floatingip']['port_id'], port_id) - # Disassociate - body = self._update('floatingips', fip['floatingip']['id'], - {'floatingip': {'port_id': None}}) - body = self._show('floatingips', fip['floatingip']['id']) - self.assertIsNone(body['floatingip']['port_id']) - self.assertIsNone(body['floatingip']['fixed_ip_address']) + plugin = manager.NeutronManager.get_plugin() + with mock.patch.object(plugin, 'notify_routers_updated') as notify: + with self.floatingip_no_assoc(private_sub) as fip: + port_id = p['port']['id'] + body = self._update('floatingips', fip['floatingip']['id'], + {'floatingip': {'port_id': port_id}}) + self.assertEqual(body['floatingip']['port_id'], port_id) + # Disassociate + body = self._update('floatingips', fip['floatingip']['id'], + {'floatingip': {'port_id': None}}) + body = self._show('floatingips', fip['floatingip']['id']) + self.assertIsNone(body['floatingip']['port_id']) + self.assertIsNone(body['floatingip']['fixed_ip_address']) + + # check that notification was not requested + self.assertFalse(notify.called) def test_create_router_maintenance_returns_503(self): with self._create_l3_ext_network() as net: