]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
ovs-agent: Ensure integration bridge is created
authorstanzgy <stan.zgy@gmail.com>
Mon, 9 Jun 2014 09:42:12 +0000 (17:42 +0800)
committerstanzgy <stan.zgy@gmail.com>
Wed, 11 Jun 2014 01:56:16 +0000 (09:56 +0800)
ovs-agent will fail to launch if integration bridge(br-int by default) is not
existed. To fix this, the agent should check and create the bridge if necessary
during launching.

Closes-Bug: 1328076
Change-Id: Iaa6c4d766ca086deb28c8ef7310dbfdcef2c105f

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

index fa5c49d16b69b73c6cf293fc9ce9635db978b357..62e373e6e72b14527f636134e478c7d88a7698dc 100644 (file)
@@ -172,11 +172,11 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
         self.int_br_device_count = 0
 
         self.int_br = ovs_lib.OVSBridge(integ_br, self.root_helper)
+        self.setup_integration_br()
         self.int_br.set_secure_mode()
         # Stores port update notifications for processing in main rpc loop
         self.updated_ports = set()
         self.setup_rpc()
-        self.setup_integration_br()
         self.bridge_mappings = bridge_mappings
         self.setup_physical_bridges(self.bridge_mappings)
         self.local_vlan_map = {}
@@ -726,6 +726,12 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
         :param bridge_name: the name of the integration bridge.
         :returns: the integration bridge
         '''
+        # Ensure the integration bridge is created.
+        # ovs_lib.OVSBridge.create() will run
+        #   ovs-vsctl -- --may-exist add-br BRIDGE_NAME
+        # which does nothing if bridge already exists.
+        self.int_br.create()
+
         self.int_br.delete_port(cfg.CONF.OVS.int_peer_patch_port)
         self.int_br.remove_all_flows()
         # switch all traffic using L2 learning
index fa163fc43b2c23e06cf0d5ea4eee4e31129e7e56..0eebd224678362892e20b18841f3fcef83880d3b 100644 (file)
@@ -118,6 +118,8 @@ class TestOvsNeutronAgent(base.BaseTestCase):
             mock.patch('neutron.plugins.openvswitch.agent.ovs_neutron_agent.'
                        'OVSNeutronAgent.setup_ancillary_bridges',
                        return_value=[]),
+            mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
+                       'create'),
             mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
                        'set_secure_mode'),
             mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
index cb4c7cd98132c223ea2a82a6341a8a6d104782bf..94ba41a13be5cd823248015a68d3658f9f996bc2 100644 (file)
@@ -107,13 +107,14 @@ class TunnelTest(base.BaseTestCase):
         self.mock_int_bridge = self.ovs_bridges[self.INT_BRIDGE]
         self.mock_int_bridge.get_local_port_mac.return_value = '000000000001'
         self.mock_int_bridge_expected = [
-            mock.call.set_secure_mode(),
-            mock.call.get_local_port_mac(),
+            mock.call.create(),
             mock.call.delete_port('patch-tun'),
             mock.call.remove_all_flows(),
             mock.call.add_flow(priority=1, actions='normal'),
             mock.call.add_flow(priority=0, table=constants.CANARY_TABLE,
-                               actions='drop')
+                               actions='drop'),
+            mock.call.set_secure_mode(),
+            mock.call.get_local_port_mac()
         ]
 
         self.mock_map_tun_bridge = self.ovs_bridges[self.MAP_TUN_BRIDGE]