]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Handle VLAN interfaces with Linux IP wrapper
authorÉdouard Thuleau <edouard.thuleau@cloudwatt.com>
Tue, 15 Oct 2013 15:41:32 +0000 (15:41 +0000)
committerÉdouard Thuleau <edouard.thuleau@cloudwatt.com>
Tue, 15 Oct 2013 17:25:47 +0000 (17:25 +0000)
Check if the interface name contains '@' character and use the part
before that character as interface name.

Change-Id: I09eb52f4d41054a76fd140d3a3476c6cfe05226b
Closes-Bug: #1240125

neutron/agent/linux/ip_lib.py
neutron/tests/unit/test_linux_ip_lib.py

index c8a0e672a436eb7a82394e41adda08380235c058..68ef4ee626d3bf6f26f19b3f3bdaa0701da91177 100644 (file)
@@ -94,7 +94,7 @@ class IPWrapper(SubProcessBase):
                 continue
             tokens = line.split(':', 2)
             if len(tokens) >= 3:
-                name = tokens[1].strip()
+                name = tokens[1].split('@', 1)[0].strip()
 
                 if exclude_loopback and name == LOOPBACK_DEVNAME:
                     continue
index b186dbbe337052446baf40c6ac717350f8f503c2..6c4eb5d0c6792259d4a61159d9c2d5cd45d64b5d 100644 (file)
@@ -35,7 +35,10 @@ LINK_SAMPLE = [
     '3: br-int: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN '
     '\    link/ether aa:bb:cc:dd:ee:ff brd ff:ff:ff:ff:ff:ff',
     '4: gw-ddc717df-49: <BROADCAST,MULTICAST> mtu 1500 qdisc noop '
-    'state DOWN \    link/ether fe:dc:ba:fe:dc:ba brd ff:ff:ff:ff:ff:ff']
+    'state DOWN \    link/ether fe:dc:ba:fe:dc:ba brd ff:ff:ff:ff:ff:ff',
+    '5: eth0.50@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc '
+    ' noqueue master brq0b24798c-07 state UP mode DEFAULT'
+    '\    link/ether ab:04:49:b6:ab:a0 brd ff:ff:ff:ff:ff:ff']
 
 ADDR_SAMPLE = ("""
 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
@@ -164,7 +167,8 @@ class TestIpWrapper(base.BaseTestCase):
                          [ip_lib.IPDevice('lo'),
                           ip_lib.IPDevice('eth0'),
                           ip_lib.IPDevice('br-int'),
-                          ip_lib.IPDevice('gw-ddc717df-49')])
+                          ip_lib.IPDevice('gw-ddc717df-49'),
+                          ip_lib.IPDevice('eth0.50')])
 
         self.execute.assert_called_once_with('o', 'link', ('list',),
                                              'sudo', None)
@@ -176,7 +180,8 @@ class TestIpWrapper(base.BaseTestCase):
                          [ip_lib.IPDevice('lo'),
                           ip_lib.IPDevice('eth0'),
                           ip_lib.IPDevice('br-int'),
-                          ip_lib.IPDevice('gw-ddc717df-49')])
+                          ip_lib.IPDevice('gw-ddc717df-49'),
+                          ip_lib.IPDevice('eth0.50')])
 
         self.execute.assert_called_once_with('o', 'link', ('list',),
                                              'sudo', None)