Minimize ovs l2 agent calls to get_vif_port_set()

The ovs l2 agent was previously calling get_vif_port_set() on the
integration bridge once per rpc_loop() iteration and then again in
the periodic _report_state() call that returns the current device
count to the neutron service.  Since get_vif_port_set() is an
expensive call (relying on shell commands) and since there
is minimal risk associated with reporting stats that are a few
seconds old, this patch caches the device count for reuse by
_report_state().

Partial-Bug: 1177973

Change-Id: Ice73384ed1ba1e97120028cd0a9bff94a62a41a4
This commit is contained in:
Maru Newby
2013-08-22 07:57:00 +00:00
parent 1c2e111a0b
commit 1f9b4e77d9
2 changed files with 11 additions and 10 deletions

View File

@@ -222,18 +222,16 @@ class TestOvsNeutronAgent(base.BaseTestCase):
self.assertTrue(device_removed.called)
def test_report_state(self):
with contextlib.nested(
mock.patch.object(self.agent.int_br, "get_vif_port_set"),
mock.patch.object(self.agent.state_rpc, "report_state")
) as (get_vif_fn, report_st):
get_vif_fn.return_value = ["vif123", "vif234"]
with mock.patch.object(self.agent.state_rpc,
"report_state") as report_st:
self.agent.int_br_device_count = 5
self.agent._report_state()
self.assertTrue(get_vif_fn.called)
report_st.assert_called_with(self.agent.context,
self.agent.agent_state)
self.assertNotIn("start_flag", self.agent.agent_state)
self.assertEqual(
self.agent.agent_state["configurations"]["devices"], 2
self.agent.agent_state["configurations"]["devices"],
self.agent.int_br_device_count
)
def test_network_delete(self):