Skip to content

Commit

Permalink
Ignore possible suffix in iproute commands.
Browse files Browse the repository at this point in the history
Fix copied from
openstack/neutron@8ddeb4b

Change-Id: Ie66d291707ec4bf16c0ddefd89c1a3a5faac0299
Closes-Bug: #1561568
(cherry picked from commit 55bc7c3)
  • Loading branch information
Édouard Thuleau authored and Senthilnathan Murugappan committed Jan 18, 2017
1 parent ee813b1 commit b38450d
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@
'vlan id']


def remove_interface_suffix(interface):
"""Remove a possible "<if>@<endpoint>" suffix from an interface' name.
This suffix can appear in some kernel versions, and intends on specifying,
for example, a veth's pair. However, this interface name is useless to us
as further 'ip' commands require that the suffix be removed.
"""
# If '@' is not present, this will do nothing.
return interface.partition("@")[0]


class SubProcessBase(object):
def __init__(self, root_helper=None, namespace=None, force_root=False):
self.root_helper = root_helper
Expand Down Expand Up @@ -96,6 +107,8 @@ def get_devices(self, exclude_loopback=False):
if exclude_loopback and name == LOOPBACK_DEVNAME:
continue

name = remove_interface_suffix(name)

retval.append(IPDevice(name,
self.root_helper,
self.namespace))
Expand Down

0 comments on commit b38450d

Please sign in to comment.