]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
VMWare: don't notify on disassociate_floatingips()
authorIhar Hrachyshka <ihrachys@redhat.com>
Thu, 19 Jun 2014 11:58:48 +0000 (13:58 +0200)
committerIhar Hrachyshka <ihrachys@redhat.com>
Wed, 16 Jul 2014 18:42:54 +0000 (18:42 +0000)
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.

Change-Id: I9c7c32d02d466098d22df8f10448361c3d99174c
Related-Bug: 1330955

neutron/plugins/vmware/plugins/base.py
neutron/tests/unit/vmware/test_nsx_plugin.py

index 072fd20eba27affbde5c08dda8f25925142e4a74..ce403e69777c0b492b011dfa0504cd913803c955 100644 (file)
@@ -2039,7 +2039,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.
index b214add033671cac71ae2fd0a0b8d3bc6d9e8401..6e814b3855d74ec0e2dc28f16f5b4bce7a2d4e1c 100644 (file)
@@ -958,23 +958,28 @@ 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)
-                # Floating IP status should be active
-                self.assertEqual(constants.FLOATINGIP_STATUS_ACTIVE,
-                                 body['floatingip']['status'])
-                # 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'])
-                # Floating IP status should be down
-                self.assertEqual(constants.FLOATINGIP_STATUS_DOWN,
-                                 body['floatingip']['status'])
+            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)
+                    # Floating IP status should be active
+                    self.assertEqual(constants.FLOATINGIP_STATUS_ACTIVE,
+                                     body['floatingip']['status'])
+                    # 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'])
+                    # Floating IP status should be down
+                    self.assertEqual(constants.FLOATINGIP_STATUS_DOWN,
+                                     body['floatingip']['status'])
+
+                # 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: