ofagent: Remove obsolete bridge_mappings (agent side)

For ofagent, it has been superseded by physical_interface_mappings
and was planned to be removed in Kilo.

Related: blueprint ofagent-physical-interface-mappings
Change-Id: I68c7e9991a3dc14ccad709ed1a438c7c45420dd6
This commit is contained in:
YAMAMOTO Takashi
2014-10-20 14:44:13 +09:00
parent f9d3e91789
commit 0b76b13bd0
3 changed files with 3 additions and 128 deletions

View File

@@ -7,8 +7,8 @@ https://github.com/osrg/ryu/wiki/OpenStack
# -- Notes for updating from Icehouce
OVS.bridge_mappings is deprecated for ofagent. It's planned to be
removed in Kilo. Please use AGENT.physical_interface_mappings instead.
OVS.bridge_mappings is deprecated for ofagent. It was removed in Kilo.
Please use AGENT.physical_interface_mappings instead.
To mimic an existing setup with bridge_mapping, you can create
a veth pair, link one side of it to the bridge, and then specify
the other side in physical_interface_mappings.

View File

@@ -34,7 +34,6 @@ from ryu.ofproto import ofproto_v1_3 as ryu_ofp13
from neutron.agent import l2population_rpc
from neutron.agent.linux import ip_lib
from neutron.agent.linux import ovs_lib
from neutron.agent.linux import utils
from neutron.agent import rpc as agent_rpc
from neutron.agent import securitygroups_rpc as sg_rpc
from neutron.common import constants as n_const
@@ -196,8 +195,7 @@ class OFANeutronAgent(n_rpc.RpcCallback,
def __init__(self, ryuapp, integ_br, local_ip,
bridge_mappings, interface_mappings, root_helper,
polling_interval, tunnel_types=None,
veth_mtu=None):
polling_interval, tunnel_types=None):
"""Constructor.
:param ryuapp: object of the ryu app.
@@ -212,11 +210,9 @@ class OFANeutronAgent(n_rpc.RpcCallback,
:param tunnel_types: A list of tunnel types to enable support for in
the agent. If set, will automatically set enable_tunneling to
True.
:param veth_mtu: MTU size for veth interfaces.
"""
super(OFANeutronAgent, self).__init__()
self.ryuapp = ryuapp
self.veth_mtu = veth_mtu
self.root_helper = root_helper
# TODO(yamamoto): Remove this VLAN leftover
self.available_local_vlans = set(xrange(ofa_const.LOCAL_VLAN_MIN,
@@ -250,8 +246,6 @@ class OFANeutronAgent(n_rpc.RpcCallback,
self.setup_integration_br()
self.int_ofports = {}
self.setup_physical_interfaces(interface_mappings)
# TODO(yamamoto): Remove physical bridge support
self.setup_physical_bridges(bridge_mappings)
self.local_vlan_map = {}
self.tun_ofports = {}
for t in tables.TUNNEL_TYPES:
@@ -596,76 +590,6 @@ class OFANeutronAgent(n_rpc.RpcCallback,
br.setup_ofp()
br.setup_default_table()
def _phys_br_prepare_create_veth(self, br, int_veth_name, phys_veth_name):
self.int_br.delete_port(int_veth_name)
br.delete_port(phys_veth_name)
if ip_lib.device_exists(int_veth_name, self.root_helper):
ip_lib.IPDevice(int_veth_name, self.root_helper).link.delete()
# Give udev a chance to process its rules here, to avoid
# race conditions between commands launched by udev rules
# and the subsequent call to ip_wrapper.add_veth
utils.execute(['udevadm', 'settle', '--timeout=10'])
def _phys_br_create_veth(self, br, int_veth_name,
phys_veth_name, physical_network, ip_wrapper):
int_veth, phys_veth = ip_wrapper.add_veth(int_veth_name,
phys_veth_name)
int_br = self.int_br
self.int_ofports[physical_network] = int(int_br.add_port(int_veth))
self.phys_ofports[physical_network] = int(br.add_port(phys_veth))
return (int_veth, phys_veth)
def _phys_br_enable_veth_to_pass_traffic(self, int_veth, phys_veth):
# enable veth to pass traffic
int_veth.link.set_up()
phys_veth.link.set_up()
if self.veth_mtu:
# set up mtu size for veth interfaces
int_veth.link.set_mtu(self.veth_mtu)
phys_veth.link.set_mtu(self.veth_mtu)
def _phys_br_patch_physical_bridge_with_integration_bridge(
self, br, physical_network, bridge, ip_wrapper):
int_veth_name = constants.PEER_INTEGRATION_PREFIX + bridge
phys_veth_name = constants.PEER_PHYSICAL_PREFIX + bridge
self._phys_br_prepare_create_veth(br, int_veth_name, phys_veth_name)
int_veth, phys_veth = self._phys_br_create_veth(br, int_veth_name,
phys_veth_name,
physical_network,
ip_wrapper)
self._phys_br_enable_veth_to_pass_traffic(int_veth, phys_veth)
def setup_physical_bridges(self, bridge_mappings):
"""Setup the physical network bridges.
Creates physical network bridges and links them to the
integration bridge using veths.
:param bridge_mappings: map physical network names to bridge names.
"""
self.phys_brs = {}
self.phys_ofports = {}
ip_wrapper = ip_lib.IPWrapper(self.root_helper)
for physical_network, bridge in bridge_mappings.iteritems():
LOG.info(_LI("Mapping physical network %(physical_network)s to "
"bridge %(bridge)s"),
{'physical_network': physical_network,
'bridge': bridge})
# setup physical bridge
if not ip_lib.device_exists(bridge, self.root_helper):
LOG.error(_LE("Bridge %(bridge)s for physical network "
"%(physical_network)s does not exist. Agent "
"terminated!"),
{'physical_network': physical_network,
'bridge': bridge})
raise SystemExit(1)
br = Bridge(bridge, self.root_helper, self.ryuapp)
self.phys_brs[physical_network] = br
self._phys_br_patch_physical_bridge_with_integration_bridge(
br, physical_network, bridge, ip_wrapper)
def setup_physical_interfaces(self, interface_mappings):
"""Setup the physical network interfaces.
@@ -1001,7 +925,6 @@ def create_agent_config_map(config):
root_helper=config.AGENT.root_helper,
polling_interval=config.AGENT.polling_interval,
tunnel_types=config.AGENT.tunnel_types,
veth_mtu=config.AGENT.veth_mtu,
)
# If enable_tunneling is TRUE, set tunnel_type to default to GRE

View File

@@ -28,8 +28,6 @@ import netaddr
from oslo.config import cfg
import testtools
from neutron.agent.linux import ip_lib
from neutron.agent.linux import utils
from neutron.common import constants as n_const
from neutron.openstack.common import importutils
from neutron.plugins.common import constants as p_const
@@ -220,10 +218,7 @@ class TestOFANeutronAgent(ofa_test_base.OFAAgentTestBase):
self.int_dp = self._mk_test_dp('int_br')
self.agent.int_br = self._mk_test_br('int_br')
self.agent.int_br.set_dp(self.int_dp)
self.agent.phys_brs['phys-net1'] = self._mk_test_br('phys_br1')
self.agent.phys_ofports['phys-net1'] = 777
self.agent.int_ofports['phys-net1'] = 666
self.datapath = self._mk_test_dp('phys_br')
def _create_tunnel_port_name(self, tunnel_ip, tunnel_type):
tunnel_ip_hex = '%08x' % netaddr.IPAddress(tunnel_ip, version=4)
@@ -448,49 +443,6 @@ class TestOFANeutronAgent(ofa_test_base.OFAAgentTestBase):
physical_network="physnet")
self.assertEqual(set(['tapb1981919-f5']), self.agent.updated_ports)
def test_setup_physical_bridges(self):
with contextlib.nested(
mock.patch.object(ip_lib, "device_exists"),
mock.patch.object(utils, "execute"),
mock.patch.object(self.mod_agent.Bridge, "add_port"),
mock.patch.object(self.mod_agent.Bridge, "delete_port"),
mock.patch.object(self.mod_agent.Bridge, "set_protocols"),
mock.patch.object(self.mod_agent.Bridge, "set_controller"),
mock.patch.object(self.mod_agent.Bridge, "get_datapath_id",
return_value='0xa'),
mock.patch.object(self.agent.int_br, "add_port"),
mock.patch.object(self.agent.int_br, "delete_port"),
mock.patch.object(ip_lib.IPWrapper, "add_veth"),
mock.patch.object(ip_lib.IpLinkCommand, "delete"),
mock.patch.object(ip_lib.IpLinkCommand, "set_up"),
mock.patch.object(ip_lib.IpLinkCommand, "set_mtu"),
mock.patch.object(self.mod_agent.ryu_api, "get_datapath",
return_value=self.datapath)
) as (devex_fn, utilsexec_fn,
ovs_addport_fn, ovs_delport_fn, ovs_set_protocols_fn,
ovs_set_controller_fn, ovs_datapath_id_fn, br_addport_fn,
br_delport_fn, addveth_fn, linkdel_fn, linkset_fn, linkmtu_fn,
ryu_api_fn):
devex_fn.return_value = True
parent = mock.MagicMock()
parent.attach_mock(utilsexec_fn, 'utils_execute')
parent.attach_mock(linkdel_fn, 'link_delete')
parent.attach_mock(addveth_fn, 'add_veth')
addveth_fn.return_value = (ip_lib.IPDevice("int-br-eth1"),
ip_lib.IPDevice("phy-br-eth1"))
ovs_addport_fn.return_value = "25"
br_addport_fn.return_value = "11"
self.agent.setup_physical_bridges({"physnet1": "br-eth"})
expected_calls = [mock.call.link_delete(),
mock.call.utils_execute(['udevadm',
'settle',
'--timeout=10']),
mock.call.add_veth('int-br-eth',
'phy-br-eth')]
parent.assert_has_calls(expected_calls, any_order=False)
self.assertEqual(11, self.agent.int_ofports["physnet1"])
self.assertEqual(25, self.agent.phys_ofports["physnet1"])
def test_setup_physical_interfaces(self):
with mock.patch.object(self.agent.int_br, "add_port") as add_port_fn:
add_port_fn.return_value = "111"