]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Use call to report state when ovs_agent starts up
authoryangxurong <yangxurong@huawei.com>
Tue, 22 Jul 2014 13:23:08 +0000 (21:23 +0800)
committeryangxurong <yangxurong@huawei.com>
Tue, 12 Aug 2014 02:23:08 +0000 (10:23 +0800)
Make sure to report ovs_agent state when starting up, otherwise
ovs_agent start_time would not be updated and thus l2pop does
not send fdb entries.

Change-Id: Idd770a85a9eabff112d9613e75d8bb524020234a
Closes-Bug: #1347452

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

index d373126cfbd103f10c6efda126fe2d914d21b86f..58917d0bc637e7c636e4177d06e7b36dfd81f017 100644 (file)
@@ -170,6 +170,7 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
         self.root_helper = root_helper
         self.available_local_vlans = set(moves.xrange(q_const.MIN_VLAN_TAG,
                                                       q_const.MAX_VLAN_TAG))
+        self.use_call = True
         self.tunnel_types = tunnel_types or []
         self.l2_pop = l2_population
         # TODO(ethuleau): Change ARP responder so it's not dependent on the
@@ -255,7 +256,9 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
             self.int_br_device_count)
         try:
             self.state_rpc.report_state(self.context,
-                                        self.agent_state)
+                                        self.agent_state,
+                                        self.use_call)
+            self.use_call = False
             self.agent_state.pop('start_flag', None)
         except Exception:
             LOG.exception(_("Failed reporting state!"))
index b7e8f3c1335b2373df5f90af7f2ff37a84363948..08ef41d09b6905f5242caec990b2bf930daaa9a4 100644 (file)
@@ -766,12 +766,27 @@ class TestOvsNeutronAgent(base.BaseTestCase):
             self.agent.int_br_device_count = 5
             self.agent._report_state()
             report_st.assert_called_with(self.agent.context,
-                                         self.agent.agent_state)
+                                         self.agent.agent_state, True)
             self.assertNotIn("start_flag", self.agent.agent_state)
+            self.assertFalse(self.agent.use_call)
             self.assertEqual(
                 self.agent.agent_state["configurations"]["devices"],
                 self.agent.int_br_device_count
             )
+            self.agent._report_state()
+            report_st.assert_called_with(self.agent.context,
+                                         self.agent.agent_state, False)
+
+    def test_report_state_fail(self):
+        with mock.patch.object(self.agent.state_rpc,
+                               "report_state") as report_st:
+            report_st.side_effect = Exception()
+            self.agent._report_state()
+            report_st.assert_called_with(self.agent.context,
+                                         self.agent.agent_state, True)
+            self.agent._report_state()
+            report_st.assert_called_with(self.agent.context,
+                                         self.agent.agent_state, True)
 
     def test_network_delete(self):
         with contextlib.nested(