]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix 'router_gateway' port status can't be updated
authorshihanzhang <shihanzhang@huawei.com>
Fri, 30 Jan 2015 01:50:52 +0000 (09:50 +0800)
committershihanzhang <shihanzhang@huawei.com>
Thu, 18 Jun 2015 06:31:24 +0000 (14:31 +0800)
when it creates a ovs bridge without parameter 'bridge-id',
it's default 'bridge-id' is None, so ovs agent should also
deal with these ovs bridges, for example if ancillary bridge
br-ex does not be handled, the 'router_gateway' port status
can't be updated.

Change-Id: If428eadadfd36a9b19ea75920120e48ac49659f2
Closes-Bug: #1416181

neutron/plugins/openvswitch/agent/ovs_neutron_agent.py
neutron/tests/unit/plugins/openvswitch/agent/test_ovs_neutron_agent.py

index d93560b07ac87dc4e935d2d75499ebd3ccc26a41..95bc8b1c466e362aac8ad393e0c38ad55d20e01a 100644 (file)
@@ -861,7 +861,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
         br_names = []
         for bridge in ovs_bridges:
             bridge_id = ovs.get_bridge_external_bridge_id(bridge)
-            if bridge_id != bridge:
+            if bridge_id and bridge_id != bridge:
                 br_names.append(bridge)
         ovs_bridges.difference_update(br_names)
         ancillary_bridges = []
index 76c4887180624abeb343a1ecf3c9cd98f87b7805..fec863aa523a1fa546e3e107b6f386f2469992bb 100644 (file)
@@ -1246,6 +1246,32 @@ class AncillaryBridgesTest(object):
         actual = self.mock_scan_ancillary_ports(vif_port_set, registered_ports)
         self.assertEqual(expected, actual)
 
+    def _test_ancillary_bridges_external(self, external_bridge_id=None):
+        bridges = ['br-int', 'br-tun', 'br-ex']
+        with mock.patch.object(self.mod_agent.OVSNeutronAgent,
+                               'setup_integration_br'),\
+                mock.patch('neutron.agent.linux.utils.get_interface_mac',
+                           return_value='00:00:00:00:00:01'),\
+                mock.patch('neutron.agent.common.ovs_lib.BaseOVS.get_bridges',
+                           return_value=bridges),\
+                mock.patch('neutron.agent.common.ovs_lib.BaseOVS.'
+                           'get_bridge_external_bridge_id',
+                           return_value=external_bridge_id),\
+                mock.patch('neutron.agent.common.ovs_lib.OVSBridge.'
+                           'get_vif_ports', return_value=[]):
+            self.agent = self.mod_agent.OVSNeutronAgent(self._bridge_classes(),
+                                                        **self.kwargs)
+            self.agent.enable_tunneling = True
+            ancillary_bridges = self.agent.setup_ancillary_bridges(
+                'br-int', 'br-tun')
+            self.assertEqual(1, len(ancillary_bridges))
+
+    def test_ancillary_bridges_external_bridge_id(self):
+        self._test_ancillary_bridges_external('br-ex')
+
+    def test_ancillary_bridges_external_bridge_id_none(self):
+        self._test_ancillary_bridges_external()
+
 
 class AncillaryBridgesTestOFCtl(AncillaryBridgesTest,
                                 ovs_test_base.OVSOFCtlTestBase):