Merge "Fix a regression in "Separate ovs-ofctl using code as a driver" change"

This commit is contained in:
Jenkins 2015-06-13 22:58:11 +00:00 committed by Gerrit Code Review
commit 1ab4fc7319
2 changed files with 63 additions and 8 deletions

View File

@ -203,14 +203,16 @@ class OVSTunnelBridge(ovs_bridge.OVSAgentBridge,
dl_vlan=vlan,
nw_dst='%s' % ip)
def setup_tunnel_port(self, network_type, port):
self.add_flow(priority=1,
def setup_tunnel_port(self, network_type, port, deferred_br=None):
br = deferred_br if deferred_br else self
br.add_flow(priority=1,
in_port=port,
actions="resubmit(,%s)" %
constants.TUN_TABLE[network_type])
def cleanup_tunnel_port(self, port):
self.delete_flows(in_port=port)
def cleanup_tunnel_port(self, port, deferred_br=None):
br = deferred_br if deferred_br else self
br.delete_flows(in_port=port)
def add_dvr_mac_tun(self, mac, port):
# Table DVR_NOT_LEARN ensures unique dvr macs in the cloud
@ -237,10 +239,12 @@ class DeferredOVSTunnelBridge(ovs_lib.DeferredOVSBridge):
'delete_flood_to_tun',
'install_arp_responder',
'delete_arp_responder',
'setup_tunnel_port',
'cleanup_tunnel_port',
]
def __getattr__(self, name):
if name in self._METHODS:
m = getattr(self.br, name)
return functools.partial(m, deferred_br=self)
raise AttributeError(name)
return super(DeferredOVSTunnelBridge, self).__getattr__(name)

View File

@ -257,3 +257,54 @@ class OVSTunnelBridgeTest(ovs_bridge_test_base.OVSBridgeTestBase,
call.delete_flows(eth_src=mac, table_id=9),
]
self.assertEqual(expected, self.mock.mock_calls)
def _mock_add_tunnel_port(self, deferred_br=False):
port_name = 'fake_port'
remote_ip = '192.168.1.3'
local_ip = '192.168.1.2'
tunnel_type = 'vxlan'
vxlan_udp_port = '4789'
dont_fragment = True
if deferred_br:
with mock.patch('neutron.agent.common.ovs_lib.OVSBridge.add_port',
return_value=9999) as add_port, \
self.br.deferred() as deferred_br:
ofport = deferred_br.add_tunnel_port(port_name, remote_ip,
local_ip, tunnel_type,
vxlan_udp_port,
dont_fragment)
else:
with mock.patch('neutron.agent.common.ovs_lib.OVSBridge.add_port',
return_value=9999) as add_port:
ofport = self.br.add_tunnel_port(port_name, remote_ip,
local_ip, tunnel_type,
vxlan_udp_port,
dont_fragment)
self.assertEqual(9999, ofport)
self.assertEqual(1, add_port.call_count)
self.assertEqual(port_name, add_port.call_args[0][0])
def _mock_delete_port(self, deferred_br=False):
port_name = 'fake_port'
if deferred_br:
with mock.patch('neutron.agent.common.ovs_lib.OVSBridge.'
'delete_port') as delete_port, \
self.br.deferred() as deferred_br:
deferred_br.delete_port(port_name)
else:
with mock.patch('neutron.agent.common.ovs_lib.OVSBridge.'
'delete_port') as delete_port:
self.br.delete_port(port_name)
self.assertEqual([call(port_name)], delete_port.mock_calls)
def test_add_tunnel_port(self):
self._mock_add_tunnel_port()
def test_delete_port(self):
self._mock_delete_port()
def test_deferred_br_add_tunnel_port(self):
self._mock_add_tunnel_port(True)
def test_deferred_br_delete_port(self):
self._mock_delete_port(True)