]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Ensure that mac address is set to namespace side veth end.
authorAkihiro MOTOKI <motoki@da.jp.nec.com>
Tue, 13 Nov 2012 11:36:09 +0000 (20:36 +0900)
committerAkihiro MOTOKI <motoki@da.jp.nec.com>
Tue, 13 Nov 2012 12:06:53 +0000 (21:06 +0900)
Fixes bug 1073350

Change-Id: I4c0e85b500ac966a4250e2b6df634aab812f67e9

quantum/agent/linux/interface.py
quantum/tests/unit/test_linux_interface.py

index a8e9dd738451b2a65c61eac73a24fba68c996bdb..bbf373807511f4550299bb8982cdd557d8cb50a4 100644 (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)
index 93256f60e0df1ce7d575575a6315d84ca7120782..6c07025e7075f1daa52a2fc3b3a6af060a2015bf 100644 (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'),