From 05c69ac6e6b394983f4014c366b1ab183f809daf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89douard=20Thuleau?= Date: Tue, 15 Oct 2013 15:41:32 +0000 Subject: [PATCH] Handle VLAN interfaces with Linux IP wrapper 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 | 2 +- neutron/tests/unit/test_linux_ip_lib.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/neutron/agent/linux/ip_lib.py b/neutron/agent/linux/ip_lib.py index c8a0e672a4..68ef4ee626 100644 --- a/neutron/agent/linux/ip_lib.py +++ b/neutron/agent/linux/ip_lib.py @@ -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 diff --git a/neutron/tests/unit/test_linux_ip_lib.py b/neutron/tests/unit/test_linux_ip_lib.py index b186dbbe33..6c4eb5d0c6 100644 --- a/neutron/tests/unit/test_linux_ip_lib.py +++ b/neutron/tests/unit/test_linux_ip_lib.py @@ -35,7 +35,10 @@ LINK_SAMPLE = [ '3: br-int: 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: 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: 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: 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)