Ensure that mac address is set to namespace side veth end.

Fixes bug 1073350

Change-Id: I4c0e85b500ac966a4250e2b6df634aab812f67e9
This commit is contained in:
Akihiro MOTOKI 2012-11-13 20:36:09 +09:00
parent 8eb8327151
commit e09051b31f
2 changed files with 8 additions and 12 deletions

View File

@ -216,19 +216,19 @@ class BridgeInterfaceDriver(LinuxInterfaceDriver):
tap_name = device_name.replace(prefix, 'tap')
else:
tap_name = device_name.replace(self.DEV_NAME_PREFIX, 'tap')
root_veth, dhcp_veth = ip.add_veth(tap_name, device_name)
root_veth.link.set_address(mac_address)
root_veth, ns_veth = ip.add_veth(tap_name, device_name)
ns_veth.link.set_address(mac_address)
if self.conf.network_device_mtu:
root_veth.link.set_mtu(self.conf.network_device_mtu)
dhcp_veth.link.set_mtu(self.conf.network_device_mtu)
ns_veth.link.set_mtu(self.conf.network_device_mtu)
if namespace:
namespace_obj = ip.ensure_namespace(namespace)
namespace_obj.add_device_to_namespace(dhcp_veth)
namespace_obj.add_device_to_namespace(ns_veth)
root_veth.link.set_up()
dhcp_veth.link.set_up()
ns_veth.link.set_up()
else:
LOG.warn(_("Device %s already exists") % device_name)

View File

@ -281,21 +281,17 @@ class TestBridgeInterfaceDriver(TestBase):
self.ip().add_veth = mock.Mock(return_value=(root_veth, ns_veth))
expected = [mock.call(c, 'sudo') for c in [
['ip', 'tuntap', 'add', 'tap0', 'mode', 'tap'],
['ip', 'link', 'set', 'tap0', 'address', 'aa:bb:cc:dd:ee:ff'],
['ip', 'link', 'set', 'tap0', 'up']]
]
self.device_exists.side_effect = device_exists
br = interface.BridgeInterfaceDriver(self.conf)
mac_address = 'aa:bb:cc:dd:ee:ff'
br.plug('01234567-1234-1234-99',
'port-1234',
'ns-0',
'aa:bb:cc:dd:ee:ff',
mac_address,
namespace=namespace)
ip_calls = [mock.call('sudo'), mock.call().add_veth('tap0', 'ns-0')]
ns_veth.assert_has_calls([mock.call.link.set_address(mac_address)])
if namespace:
ip_calls.extend([
mock.call().ensure_namespace('01234567-1234-1234-99'),