From 46501246c202f1f424f0d2a05769926303a39c89 Mon Sep 17 00:00:00 2001 From: yangxurong Date: Tue, 22 Jul 2014 21:23:08 +0800 Subject: [PATCH] Use call to report state when ovs_agent starts up 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 --- .../openvswitch/agent/ovs_neutron_agent.py | 5 ++++- .../unit/openvswitch/test_ovs_neutron_agent.py | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py index d373126cf..58917d0bc 100644 --- a/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py +++ b/neutron/plugins/openvswitch/agent/ovs_neutron_agent.py @@ -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!")) diff --git a/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py b/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py index b7e8f3c13..08ef41d09 100644 --- a/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py +++ b/neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py @@ -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(