summaryrefslogtreecommitdiff
path: root/python/vyos/ifconfig/register.py
diff options
context:
space:
mode:
authorThomas Mangin <thomas.mangin@exa.net.uk>2020-03-25 13:50:22 +0000
committerThomas Mangin <thomas.mangin@exa.net.uk>2020-03-25 18:21:36 +0000
commit9049732de30832fd5d936bf980fc597b772463ee (patch)
treea22e563f24ceb8aaa0b53c7cbe80924610b42971 /python/vyos/ifconfig/register.py
parent6e7739e0b69e1d3371ebe36218604cbb1aca18b1 (diff)
downloadvyos-1x-9049732de30832fd5d936bf980fc597b772463ee.tar.gz
vyos-1x-9049732de30832fd5d936bf980fc597b772463ee.zip
ifconfig: T2057: fix finding section name from interface
Diffstat (limited to 'python/vyos/ifconfig/register.py')
-rw-r--r--python/vyos/ifconfig/register.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/python/vyos/ifconfig/register.py b/python/vyos/ifconfig/register.py
index 2d4b0d4c0..c90782b70 100644
--- a/python/vyos/ifconfig/register.py
+++ b/python/vyos/ifconfig/register.py
@@ -57,7 +57,7 @@ class Register:
return 'input'
if name in cls._prefixes:
- return cls._prefixes[name].defintion['section']
+ return cls._prefixes[name].definition['section']
return ''
@classmethod
@@ -68,28 +68,27 @@ class Register:
raise ValueError(f'No type found for interface name: {name}')
@classmethod
- def _listing (cls):
+ def _listing (cls,section=''):
interfaces = netifaces.interfaces()
for ifname in interfaces:
- if '@' in ifname:
- # Tunnels: sit0@NONE, gre0@NONE, gretap0@NONE, erspan0@NONE, tunl0@NONE, ip6tnl0@NONE, ip6gre0@NONE
- continue
-
# XXX: Temporary hack as vti and input are not yet moved from vyatta to vyos
if ifname.startswith('vti') or ifname.startswith('input'):
yield ifname
continue
- if not cls.section(ifname):
+ ifsection = cls.section(ifname)
+ if not ifsection:
continue
+
+ if section and ifsection != section:
+ continue
+
yield ifname
@classmethod
def listing(cls, section=''):
- if not section:
- return list(cls._listing())
- return [_ for _ in cls._listing() if cls._basename(_,False) in self.prefixes]
+ return list(cls._listing(section))
# XXX: TODO - limit name for VRF interfaces