Merge "LB Trunk: Stop matching MAC of subport to port model" into stable/newton
This commit is contained in:
commit
87824370fc
@ -102,12 +102,6 @@ class LinuxBridgeTrunkDriver(trunk_rpc.TrunkSkeleton):
|
|||||||
# clear any VLANs in case this was a trunk that changed status while
|
# clear any VLANs in case this was a trunk that changed status while
|
||||||
# agent was offline.
|
# agent was offline.
|
||||||
self._plumber.delete_subports_by_port_id(device_details['port_id'])
|
self._plumber.delete_subports_by_port_id(device_details['port_id'])
|
||||||
if self._tapi.get_trunk_for_subport(context,
|
|
||||||
device_details['port_id']):
|
|
||||||
# This is a subport. We need to ensure the correct mac address is
|
|
||||||
# set now that we have the port data to see the data model MAC.
|
|
||||||
self._plumber.set_port_mac(device_details['port_id'],
|
|
||||||
device_details['mac_address'])
|
|
||||||
|
|
||||||
def wire_trunk(self, context, trunk):
|
def wire_trunk(self, context, trunk):
|
||||||
"""Wire up subports while keeping the server trunk status apprised."""
|
"""Wire up subports while keeping the server trunk status apprised."""
|
||||||
|
@ -76,25 +76,6 @@ class Plumber(object):
|
|||||||
dict(name=subname, tag=vlan_id))
|
dict(name=subname, tag=vlan_id))
|
||||||
self._safe_delete_device(subname)
|
self._safe_delete_device(subname)
|
||||||
|
|
||||||
def set_port_mac(self, port_id, mac_address):
|
|
||||||
"""Sets mac address of physical device for port_id to mac_address."""
|
|
||||||
dev_name = self._get_tap_device_name(port_id)
|
|
||||||
ipd = ip_lib.IPDevice(dev_name, namespace=self.namespace)
|
|
||||||
try:
|
|
||||||
if mac_address == ipd.link.address:
|
|
||||||
return False
|
|
||||||
LOG.debug("Changing MAC from %(old)s to %(new)s for device "
|
|
||||||
"%(dev)s", dict(old=ipd.link.address, new=mac_address,
|
|
||||||
dev=dev_name))
|
|
||||||
ipd.link.set_down()
|
|
||||||
ipd.link.set_address(mac_address)
|
|
||||||
ipd.link.set_up()
|
|
||||||
except Exception:
|
|
||||||
with excutils.save_and_reraise_exception() as ectx:
|
|
||||||
ectx.reraise = ip_lib.IPDevice(
|
|
||||||
dev_name, namespace=self.namespace).exists()
|
|
||||||
return True
|
|
||||||
|
|
||||||
def _trunk_lock(self, trunk_dev):
|
def _trunk_lock(self, trunk_dev):
|
||||||
lock_name = 'trunk-%s' % trunk_dev
|
lock_name = 'trunk-%s' % trunk_dev
|
||||||
return lockutils.lock(lock_name, utils.SYNCHRONIZED_PREFIX)
|
return lockutils.lock(lock_name, utils.SYNCHRONIZED_PREFIX)
|
||||||
|
@ -18,7 +18,6 @@ from oslo_utils import uuidutils
|
|||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
from neutron.agent.linux import ip_lib
|
from neutron.agent.linux import ip_lib
|
||||||
from neutron.common import utils
|
|
||||||
from neutron.objects import trunk
|
from neutron.objects import trunk
|
||||||
from neutron.plugins.ml2.drivers.linuxbridge.agent import \
|
from neutron.plugins.ml2.drivers.linuxbridge.agent import \
|
||||||
linuxbridge_neutron_agent
|
linuxbridge_neutron_agent
|
||||||
@ -60,19 +59,6 @@ class LinuxBridgeAgentTests(test_ip_lib.IpLibTestFramework):
|
|||||||
name='br-eth1'))
|
name='br-eth1'))
|
||||||
lba.LinuxBridgeManager(mappings, {})
|
lba.LinuxBridgeManager(mappings, {})
|
||||||
|
|
||||||
def test_set_port_mac(self):
|
|
||||||
attr = self.generate_device_details()
|
|
||||||
self.manage_device(attr)
|
|
||||||
plumber = trunk_plumber.Plumber(namespace=attr.namespace)
|
|
||||||
# force it to return name of above
|
|
||||||
plumber._get_tap_device_name = lambda x: attr.name
|
|
||||||
new_mac = utils.get_random_mac('fa:16:3e:00:00:00'.split(':'))
|
|
||||||
self.assertTrue(plumber.set_port_mac('port_id', new_mac))
|
|
||||||
self.assertFalse(plumber.set_port_mac('port_id', new_mac))
|
|
||||||
new_mac = utils.get_random_mac('fa:16:3e:00:00:00'.split(':'))
|
|
||||||
self.assertTrue(plumber.set_port_mac('port_id', new_mac))
|
|
||||||
self.assertFalse(plumber.set_port_mac('port_id', new_mac))
|
|
||||||
|
|
||||||
def test_vlan_subinterfaces(self):
|
def test_vlan_subinterfaces(self):
|
||||||
attr = self.generate_device_details()
|
attr = self.generate_device_details()
|
||||||
device = self.manage_device(attr)
|
device = self.manage_device(attr)
|
||||||
|
@ -103,10 +103,6 @@ class LinuxBridgeTrunkDriverTestCase(base.BaseTestCase):
|
|||||||
'mac_address': 'mac_addr'})
|
'mac_address': 'mac_addr'})
|
||||||
self.plumber.delete_subports_by_port_id.assert_called_once_with(
|
self.plumber.delete_subports_by_port_id.assert_called_once_with(
|
||||||
self.trunk.sub_ports[0].port_id)
|
self.trunk.sub_ports[0].port_id)
|
||||||
self.tapi.get_trunk_for_subport.assert_called_once_with(
|
|
||||||
mock.ANY, self.trunk.sub_ports[0].port_id)
|
|
||||||
self.plumber.set_port_mac.assert_called_once_with(
|
|
||||||
self.trunk.sub_ports[0].port_id, 'mac_addr')
|
|
||||||
|
|
||||||
def test_wire_trunk_happy_path(self):
|
def test_wire_trunk_happy_path(self):
|
||||||
self.lbd.wire_trunk('ctx', self.trunk)
|
self.lbd.wire_trunk('ctx', self.trunk)
|
||||||
|
@ -68,16 +68,6 @@ class PlumberTestCase(base.BaseTestCase):
|
|||||||
mock.call('dev1')],
|
mock.call('dev1')],
|
||||||
any_order=True)
|
any_order=True)
|
||||||
|
|
||||||
def test_set_port_mac(self):
|
|
||||||
ipd = mock.patch.object(trunk_plumber.ip_lib, 'IPDevice').start()
|
|
||||||
ipdi = ipd.return_value
|
|
||||||
self.plumber.set_port_mac('port_id', mac_address='44')
|
|
||||||
ipdi.link.set_address.assert_called_once_with('44')
|
|
||||||
ipdi.exists.return_value = False
|
|
||||||
ipdi.link.set_address.side_effect = ValueError()
|
|
||||||
# exception suppressed since it no longer 'exists'
|
|
||||||
self.plumber.set_port_mac('port_id', mac_address='44')
|
|
||||||
|
|
||||||
def test__get_vlan_children(self):
|
def test__get_vlan_children(self):
|
||||||
expected = [('tap47198374-5a', 777),
|
expected = [('tap47198374-5a', 777),
|
||||||
('tap47198374-5b', 2),
|
('tap47198374-5b', 2),
|
||||||
|
Loading…
Reference in New Issue
Block a user