Browse Source

changes ovs agent to get bridges via ovs_lib

ip_lib is currently used to list the bridges
in the Open vSwitch neutron agent.

use of ip_lib blocks reuse of the Open vSwitch agent
with userspace only open vSwitchs implementations.

this patch replaces calls to ip_lib with ovs_lib.get_bridges

Closes-Bug: #1331569
Change-Id: I5935d39b314055063a64266bda0cc4c2d1ac05fc
changes/65/101965/5
Sean Mooney 7 years ago
parent
commit
1b46d36269
3 changed files with 12 additions and 10 deletions
  1. +2
    -1
      neutron/plugins/openvswitch/agent/ovs_neutron_agent.py
  2. +7
    -3
      neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py
  3. +3
    -6
      neutron/tests/unit/openvswitch/test_ovs_tunnel.py

+ 2
- 1
neutron/plugins/openvswitch/agent/ovs_neutron_agent.py View File

@ -898,13 +898,14 @@ class OVSNeutronAgent(n_rpc.RpcCallback,
self.int_ofports = {}
self.phys_ofports = {}
ip_wrapper = ip_lib.IPWrapper(self.root_helper)
ovs_bridges = ovs_lib.get_bridges(self.root_helper)
for physical_network, bridge in bridge_mappings.iteritems():
LOG.info(_("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):
if bridge not in ovs_bridges:
LOG.error(_("Bridge %(bridge)s for physical network "
"%(physical_network)s does not exist. Agent "
"terminated!"),


+ 7
- 3
neutron/tests/unit/openvswitch/test_ovs_neutron_agent.py View File

@ -125,6 +125,8 @@ class TestOvsNeutronAgent(base.BaseTestCase):
return_value='00:00:00:00:00:01'),
mock.patch('neutron.agent.linux.utils.get_interface_mac',
return_value='00:00:00:00:00:01'),
mock.patch('neutron.agent.linux.ovs_lib.'
'get_bridges'),
mock.patch('neutron.openstack.common.loopingcall.'
'FixedIntervalLoopingCall',
new=MockFixedIntervalLoopingCall),
@ -516,10 +518,11 @@ class TestOvsNeutronAgent(base.BaseTestCase):
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(ip_lib.IpLinkCommand, "set_mtu"),
mock.patch.object(ovs_lib, "get_bridges")
) as (devex_fn, sysexit_fn, utilsexec_fn, remflows_fn, ovs_addfl_fn,
ovs_addport_fn, ovs_delport_fn, br_addport_fn,
br_delport_fn, addveth_fn, linkdel_fn, linkset_fn, linkmtu_fn):
ovs_addport_fn, ovs_delport_fn, br_addport_fn, br_delport_fn,
addveth_fn, linkdel_fn, linkset_fn, linkmtu_fn, get_br_fn):
devex_fn.return_value = True
parent = mock.MagicMock()
parent.attach_mock(utilsexec_fn, 'utils_execute')
@ -529,6 +532,7 @@ class TestOvsNeutronAgent(base.BaseTestCase):
ip_lib.IPDevice("phy-br-eth1"))
ovs_addport_fn.return_value = "int_ofport"
br_addport_fn.return_value = "phys_veth"
get_br_fn.return_value = ["br-eth"]
self.agent.setup_physical_bridges({"physnet1": "br-eth"})
expected_calls = [mock.call.link_delete(),
mock.call.utils_execute(['/sbin/udevadm',


+ 3
- 6
neutron/tests/unit/openvswitch/test_ovs_tunnel.py View File

@ -241,14 +241,12 @@ class TunnelTest(base.BaseTestCase):
actions="drop")
]
self.device_exists_expected = [
mock.call(self.MAP_TUN_BRIDGE, 'sudo'),
]
self.device_exists_expected = []
self.ipdevice_expected = []
self.ipwrapper_expected = [mock.call('sudo')]
self.get_bridges_expected = [mock.call('sudo')]
self.get_bridges_expected = [mock.call('sudo'), mock.call('sudo')]
self.inta_expected = []
self.intb_expected = []
@ -656,7 +654,6 @@ class TunnelTestUseVethInterco(TunnelTest):
]
self.device_exists_expected = [
mock.call(self.MAP_TUN_BRIDGE, 'sudo'),
mock.call('int-%s' % self.MAP_TUN_BRIDGE, 'sudo'),
]
@ -670,7 +667,7 @@ class TunnelTestUseVethInterco(TunnelTest):
'phy-%s' % self.MAP_TUN_BRIDGE)
]
self.get_bridges_expected = [mock.call('sudo')]
self.get_bridges_expected = [mock.call('sudo'), mock.call('sudo')]
self.inta_expected = [mock.call.link.set_up()]
self.intb_expected = [mock.call.link.set_up()]


Loading…
Cancel
Save