]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Big Switch: Send notification after port update
authorAngus Lees <gus@inodes.org>
Thu, 28 Aug 2014 04:42:18 +0000 (14:42 +1000)
committerAngus Lees <gus@inodes.org>
Wed, 29 Oct 2014 01:04:51 +0000 (12:04 +1100)
The Big Switch plugin was not sending port update
notifications for security group changes after the
port was updated. This patch corrects that behavior
by calling the port_update method on the RPC notifier
when necessary after a port update.

Closes-Bug: #1376527
Change-Id: Ic2fd872725c1da8e2dc394473b7feb407d21268f

neutron/plugins/bigswitch/plugin.py
neutron/tests/unit/bigswitch/test_restproxy_plugin.py

index e7d467ba3e1c788d2b35fec72380c9d441064cd4..ef976f30ad856cb2c724560acfd21a9e9c308e97 100644 (file)
@@ -785,11 +785,14 @@ class NeutronRestProxyV2(NeutronRestProxyV2Base,
                 self.servers.rest_update_port(net_tenant_id,
                                               new_port["network_id"],
                                               mapped_port)
-            agent_update_required = self.update_security_group_on_port(
+            need_port_update_notify = self.update_security_group_on_port(
                 context, port_id, port, orig_port, new_port)
-        agent_update_required |= self.is_security_group_member_updated(
+        need_port_update_notify |= self.is_security_group_member_updated(
             context, orig_port, new_port)
 
+        if need_port_update_notify:
+            self.notifier.port_update(context, new_port)
+
         # return new_port
         return new_port
 
index 87391cf945e2307da70d46d8aa5da5161841d31a..f96cc656ca439076e4cce480d90cfe809a15d91f 100644 (file)
@@ -294,6 +294,20 @@ class TestBigSwitchProxyNetworksV2(test_plugin.TestNetworksV2,
                              self._get_networks(n['network']['tenant_id']
                                                 )[0]['id'])
 
+    def test_notify_on_security_group_change(self):
+        plugin = manager.NeutronManager.get_plugin()
+        with self.port() as p:
+            with contextlib.nested(
+                mock.patch.object(plugin, 'notifier'),
+                mock.patch.object(plugin, 'is_security_group_member_updated',
+                                  return_value=True)
+            ) as (n_mock, s_mock):
+                # any port update should trigger a notification due to s_mock
+                data = {'port': {'name': 'aNewName'}}
+                self.new_update_request(
+                    'ports', data, p['port']['id']).get_response(self.api)
+                self.assertTrue(n_mock.port_update.called)
+
 
 class TestBigSwitchProxySubnetsV2(test_plugin.TestSubnetsV2,
                                   BigSwitchProxyPluginV2TestCase):