Merge "Ensure that tunnels are fully reset on ovs restart"

This commit is contained in:
Jenkins 2016-01-26 14:15:54 +00:00 committed by Gerrit Code Review
commit 59a429efe2
2 changed files with 29 additions and 4 deletions

View File

@ -198,9 +198,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
self.setup_physical_bridges(self.bridge_mappings)
self.local_vlan_map = {}
self.tun_br_ofports = {p_const.TYPE_GENEVE: {},
p_const.TYPE_GRE: {},
p_const.TYPE_VXLAN: {}}
self._reset_tunnel_ofports()
self.polling_interval = agent_conf.polling_interval
self.minimize_polling = agent_conf.minimize_polling
@ -351,6 +349,11 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
self.available_local_vlans.update(self._local_vlan_hints.values())
self._local_vlan_hints = {}
def _reset_tunnel_ofports(self):
self.tun_br_ofports = {p_const.TYPE_GENEVE: {},
p_const.TYPE_GRE: {},
p_const.TYPE_VXLAN: {}}
def setup_rpc(self):
self.plugin_rpc = OVSPluginApi(topics.PLUGIN)
self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN)
@ -1852,6 +1855,7 @@ class OVSNeutronAgent(sg_rpc.SecurityGroupAgentRpcCallbackMixin,
self.setup_integration_br()
self.setup_physical_bridges(self.bridge_mappings)
if self.enable_tunneling:
self._reset_tunnel_ofports()
self.setup_tunnel_br()
self.setup_tunnel_br_flows()
tunnel_sync = True

View File

@ -1530,6 +1530,12 @@ class TestOvsNeutronAgent(object):
self.agent.tunnel_delete(context=None, **kwargs)
self.assertTrue(clean_tun_fn.called)
def test_reset_tunnel_ofports(self):
tunnel_handles = self.agent.tun_br_ofports
self.agent.tun_br_ofports = {'gre': {'10.10.10.10': '1'}}
self.agent._reset_tunnel_ofports()
self.assertEqual(self.agent.tun_br_ofports, tunnel_handles)
def _test_ovs_status(self, *args):
reply2 = {'current': set(['tap0']),
'added': set(['tap2']),
@ -1543,6 +1549,8 @@ class TestOvsNeutronAgent(object):
'added': set([]),
'removed': set([])}
self.agent.enable_tunneling = True
with mock.patch.object(async_process.AsyncProcess, "_spawn"),\
mock.patch.object(async_process.AsyncProcess, "start"),\
mock.patch.object(async_process.AsyncProcess, "stop"),\
@ -1564,7 +1572,15 @@ class TestOvsNeutronAgent(object):
self.mod_agent.OVSNeutronAgent,
'update_stale_ofport_rules') as update_stale, \
mock.patch.object(self.mod_agent.OVSNeutronAgent,
'cleanup_stale_flows') as cleanup:
'cleanup_stale_flows') as cleanup, \
mock.patch.object(self.mod_agent.OVSNeutronAgent,
'setup_tunnel_br') as setup_tunnel_br,\
mock.patch.object(
self.mod_agent.OVSNeutronAgent,
'setup_tunnel_br_flows') as setup_tunnel_br_flows,\
mock.patch.object(
self.mod_agent.OVSNeutronAgent,
'_reset_tunnel_ofports') as reset_tunnel_ofports:
log_exception.side_effect = Exception(
'Fake exception to get out of the loop')
devices_not_ready = set()
@ -1602,6 +1618,11 @@ class TestOvsNeutronAgent(object):
# re-setup the bridges
setup_int_br.assert_has_calls([mock.call()])
setup_phys_br.assert_has_calls([mock.call({})])
# Ensure that tunnel handles are reset and bridge
# and flows reconfigured.
self.assertTrue(reset_tunnel_ofports.called)
self.assertTrue(setup_tunnel_br_flows.called)
self.assertTrue(setup_tunnel_br.called)
def test_ovs_status(self):
self._test_ovs_status(constants.OVS_NORMAL,