]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
move rpc_setup to the last step of __init__
authorYong Sheng Gong <gongysh@unitedstack.com>
Mon, 9 Dec 2013 13:01:17 +0000 (21:01 +0800)
committerYong Sheng Gong <gongysh@unitedstack.com>
Wed, 11 Dec 2013 06:52:14 +0000 (14:52 +0800)
rpc setup should be the last stuff in agent initialization
so that the rcp message handler(the agent instance itself)
can have a fully initialized agent instance.

Change-Id: I58c966e2c8ee92c307b565932e867b5d1ec73b67
Closes-Bug: #1259088

neutron/plugins/linuxbridge/agent/linuxbridge_neutron_agent.py
neutron/plugins/openvswitch/agent/ovs_neutron_agent.py
neutron/tests/unit/openvswitch/test_ovs_tunnel.py

index 1eac636e2c30a5eef62e3e47d8f9912fb33de1b8..3fabd0fe6aeff36ccbc2f4edec40aaa072d90c03 100755 (executable)
@@ -792,8 +792,10 @@ class LinuxBridgeNeutronAgentRPC(sg_rpc.SecurityGroupAgentRpcMixin):
             'agent_type': constants.AGENT_TYPE_LINUXBRIDGE,
             'start_flag': True}
 
-        self.setup_rpc(interface_mappings.values())
         self.init_firewall()
+        # Perform rpc initialization only once all other configuration
+        # is complete
+        self.setup_rpc(interface_mappings.values())
 
     def _report_state(self):
         try:
index cf2243e8a6625eb2235f9544602c5f54f570b081..d47986e0160c7a17603802a153d2cf895abf7ef4 100644 (file)
@@ -200,7 +200,6 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
         self.int_br_device_count = 0
 
         self.int_br = ovs_lib.OVSBridge(integ_br, self.root_helper)
-        self.setup_rpc()
         self.setup_integration_br()
         self.setup_physical_bridges(bridge_mappings)
         self.local_vlan_map = {}
@@ -224,12 +223,11 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
         # Collect additional bridges to monitor
         self.ancillary_brs = self.setup_ancillary_bridges(integ_br, tun_br)
 
-        # Security group agent supprot
-        self.sg_agent = OVSSecurityGroupAgent(self.context,
-                                              self.plugin_rpc,
-                                              root_helper)
         # Initialize iteration counter
         self.iter_num = 0
+        # Perform rpc initialization only once all other configuration
+        # is complete
+        self.setup_rpc()
 
     def _check_ovs_version(self):
         if constants.TYPE_VXLAN in self.tunnel_types:
@@ -253,9 +251,13 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
         self.topic = topics.AGENT
         self.plugin_rpc = OVSPluginApi(topics.PLUGIN)
         self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)
-
         # RPC network init
         self.context = context.get_admin_context_without_session()
+        # prepare sg_agent for Security group support
+        # before we enable RPC handler
+        self.sg_agent = OVSSecurityGroupAgent(self.context,
+                                              self.plugin_rpc,
+                                              self.root_helper)
         # Handle updates from service
         self.dispatcher = self.create_rpc_dispatcher()
         # Define the listening consumers for the agent
index 76bf083661bd152a1211716f8f67690807b7e0db..b3b219ae565f1cdac5c5231c09af8aecc70e9850 100644 (file)
@@ -100,7 +100,6 @@ 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.get_local_port_mac(),
             mock.call.delete_port('patch-tun'),
             mock.call.remove_all_flows(),
             mock.call.add_flow(priority=1, actions='normal'),
@@ -217,6 +216,8 @@ class TunnelTest(base.BaseTestCase):
         self.execute = mock.patch('neutron.agent.linux.utils.execute').start()
         self.execute_expected = [mock.call(['/sbin/udevadm', 'settle',
                                             '--timeout=10'])]
+        self.mock_int_bridge_expected += [
+            mock.call.get_local_port_mac()]
 
     def _verify_mock_call(self, mock_obj, expected):
         mock_obj.assert_has_calls(expected)