Merge "Cleanup of the veth related code from ovs agent"
This commit is contained in:
commit
2ceff4acea
@ -133,8 +133,8 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
|
||||
connect local VLANs on the integration bridge to inter-hypervisor
|
||||
tunnels on the tunnel bridge.
|
||||
|
||||
For each virtual network realized as a VLAN or flat network, a
|
||||
veth or a pair of patch ports is used to connect the local VLAN on
|
||||
For each virtual network realized as a VLAN or flat network,
|
||||
a pair of patch ports is used to connect the local VLAN on
|
||||
the integration bridge with the physical network bridge, with flow
|
||||
rules adding, modifying, or stripping VLAN tags as necessary.
|
||||
'''
|
||||
@ -1623,7 +1623,7 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
|
||||
'''Setup the physical network bridges.
|
||||
|
||||
Creates physical network bridges and links them to the
|
||||
integration bridge using veths or patch ports.
|
||||
integration bridge using patch ports.
|
||||
|
||||
:param bridge_mappings: map physical network names to bridge names.
|
||||
'''
|
||||
@ -1656,26 +1656,11 @@ class OVSNeutronAgent(l2population_rpc.L2populationRpcCallBackTunnelMixin,
|
||||
br.setup_default_table()
|
||||
self.phys_brs[physical_network] = br
|
||||
|
||||
# interconnect physical and integration bridges using veth/patches
|
||||
# interconnect physical and integration bridges using patches
|
||||
int_if_name = plugin_utils.get_interface_name(
|
||||
bridge, prefix=ovs_const.PEER_INTEGRATION_PREFIX)
|
||||
phys_if_name = plugin_utils.get_interface_name(
|
||||
bridge, prefix=ovs_const.PEER_PHYSICAL_PREFIX)
|
||||
# Interface type of port for physical and integration bridges must
|
||||
# be same, so check only one of them.
|
||||
# Not logging error here, as the interface may not exist yet.
|
||||
# Type check is done to cleanup wrong interface if any.
|
||||
|
||||
# TODO(slaweq) In X release we can remove code which is here just
|
||||
# to move from old "veth" interconnection between bridges to the
|
||||
# patch ports (L1527 - L1547)
|
||||
int_type = self.int_br.db_get_val("Interface", int_if_name, "type",
|
||||
log_errors=False)
|
||||
# Drop ports if the interface type doesn't match the
|
||||
# configuration value
|
||||
if int_type == 'veth':
|
||||
self.int_br.delete_port(int_if_name)
|
||||
br.delete_port(phys_if_name)
|
||||
|
||||
# Setup int_br to physical bridge patches. If they already
|
||||
# exist we leave them alone, otherwise we create them but don't
|
||||
|
@ -1668,11 +1668,6 @@ class TestOvsNeutronAgent(object):
|
||||
mock.call.phys_br.set_secure_mode(),
|
||||
mock.call.phys_br.setup_controllers(mock.ANY),
|
||||
mock.call.phys_br.setup_default_table(),
|
||||
mock.call.int_br.db_get_val('Interface', 'int-br-eth',
|
||||
'type', log_errors=False),
|
||||
# Have to use __getattr__ here to avoid mock._Call.__eq__
|
||||
# method being called
|
||||
mock.call.int_br.db_get_val().__getattr__('__eq__')('veth'),
|
||||
mock.call.int_br.port_exists('int-br-eth'),
|
||||
]
|
||||
if port_exists:
|
||||
@ -1735,85 +1730,6 @@ class TestOvsNeutronAgent(object):
|
||||
def test_setup_physical_bridges_recreate(self):
|
||||
self._test_setup_physical_bridges(recreate=True)
|
||||
|
||||
def _test_setup_physical_bridges_change_from_veth_to_patch_conf(
|
||||
self, port_exists=False):
|
||||
with mock.patch.object(sys, "exit"),\
|
||||
mock.patch.object(self.agent, 'br_phys_cls') as phys_br_cls,\
|
||||
mock.patch.object(self.agent, 'int_br') as int_br,\
|
||||
mock.patch.object(self.agent.int_br, 'db_get_val',
|
||||
return_value='veth'), \
|
||||
mock.patch.object(self.agent, '_check_bridge_datapath_id'), \
|
||||
mock.patch.object(ovs_lib.BaseOVS, 'get_bridges'):
|
||||
phys_br = phys_br_cls()
|
||||
parent = mock.MagicMock()
|
||||
parent.attach_mock(phys_br_cls, 'phys_br_cls')
|
||||
parent.attach_mock(phys_br, 'phys_br')
|
||||
parent.attach_mock(int_br, 'int_br')
|
||||
if port_exists:
|
||||
phys_br.get_port_ofport.return_value = "phy_ofport"
|
||||
int_br.get_port_ofport.return_value = "int_ofport"
|
||||
else:
|
||||
phys_br.add_patch_port.return_value = "phy_ofport"
|
||||
int_br.add_patch_port.return_value = "int_ofport"
|
||||
phys_br.port_exists.return_value = port_exists
|
||||
int_br.port_exists.return_value = port_exists
|
||||
self.agent.setup_physical_bridges({"physnet1": "br-eth"})
|
||||
expected_calls = [
|
||||
mock.call.phys_br_cls('br-eth'),
|
||||
mock.call.phys_br.create(),
|
||||
mock.call.phys_br.set_secure_mode(),
|
||||
mock.call.phys_br.setup_controllers(mock.ANY),
|
||||
mock.call.phys_br.setup_default_table(),
|
||||
mock.call.int_br.delete_port('int-br-eth'),
|
||||
mock.call.phys_br.delete_port('phy-br-eth'),
|
||||
mock.call.int_br.port_exists('int-br-eth'),
|
||||
]
|
||||
if port_exists:
|
||||
expected_calls += [
|
||||
mock.call.int_br.get_port_ofport('int-br-eth'),
|
||||
]
|
||||
else:
|
||||
expected_calls += [
|
||||
mock.call.int_br.add_patch_port(
|
||||
'int-br-eth', ovs_constants.NONEXISTENT_PEER),
|
||||
]
|
||||
expected_calls += [
|
||||
mock.call.int_br.set_igmp_snooping_flood('int-br-eth'),
|
||||
mock.call.phys_br.port_exists('phy-br-eth'),
|
||||
]
|
||||
if port_exists:
|
||||
expected_calls += [
|
||||
mock.call.phys_br.get_port_ofport('phy-br-eth'),
|
||||
]
|
||||
else:
|
||||
expected_calls += [
|
||||
mock.call.phys_br.add_patch_port(
|
||||
'phy-br-eth', ovs_constants.NONEXISTENT_PEER),
|
||||
]
|
||||
expected_calls += [
|
||||
mock.call.int_br.drop_port(in_port='int_ofport'),
|
||||
mock.call.phys_br.drop_port(in_port='phy_ofport'),
|
||||
mock.call.int_br.set_db_attribute('Interface', 'int-br-eth',
|
||||
'options',
|
||||
{'peer': 'phy-br-eth'}),
|
||||
mock.call.phys_br.set_db_attribute('Interface', 'phy-br-eth',
|
||||
'options',
|
||||
{'peer': 'int-br-eth'}),
|
||||
]
|
||||
parent.assert_has_calls(expected_calls)
|
||||
self.assertEqual("int_ofport",
|
||||
self.agent.int_ofports["physnet1"])
|
||||
self.assertEqual("phy_ofport",
|
||||
self.agent.phys_ofports["physnet1"])
|
||||
|
||||
def test_setup_physical_bridges_change_from_veth_to_patch_conf(self):
|
||||
self._test_setup_physical_bridges_change_from_veth_to_patch_conf()
|
||||
|
||||
def test_setup_physical_bridges_change_from_veth_to_patch_conf_port_exists(
|
||||
self):
|
||||
self._test_setup_physical_bridges_change_from_veth_to_patch_conf(
|
||||
port_exists=True)
|
||||
|
||||
def test_setup_tunnel_br(self):
|
||||
self.tun_br = mock.Mock()
|
||||
with mock.patch.object(self.agent.int_br,
|
||||
|
@ -166,8 +166,6 @@ class TunnelTest(object):
|
||||
self.ipdevice = mock.patch.object(ip_lib, 'IPDevice').start()
|
||||
|
||||
self.ipwrapper = mock.patch.object(ip_lib, 'IPWrapper').start()
|
||||
add_veth = self.ipwrapper.return_value.add_veth
|
||||
add_veth.return_value = [self.inta, self.intb]
|
||||
|
||||
self.get_bridges = mock.patch.object(ovs_lib.BaseOVS,
|
||||
'get_bridges').start()
|
||||
@ -223,8 +221,6 @@ class TunnelTest(object):
|
||||
ovs_constants.NONEXISTENT_PEER),
|
||||
]
|
||||
self.mock_int_bridge_expected += [
|
||||
mock.call.db_get_val('Interface', 'int-%s' % self.MAP_TUN_BRIDGE,
|
||||
'type', log_errors=False),
|
||||
mock.call.port_exists('int-%s' % self.MAP_TUN_BRIDGE),
|
||||
mock.call.add_patch_port('int-%s' % self.MAP_TUN_BRIDGE,
|
||||
ovs_constants.NONEXISTENT_PEER),
|
||||
|
Loading…
Reference in New Issue
Block a user