diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-03-25 19:43:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-25 19:43:48 +0100 |
commit | ad6625d63f577dacc2760a6b2b658b2ceaeed119 (patch) | |
tree | 139d76cd0153565f322e7e620857d18cd30fe5f0 /python/vyos | |
parent | 0e4a28ca478e26632938f12e91a97b09327673e1 (diff) | |
parent | 9049732de30832fd5d936bf980fc597b772463ee (diff) | |
download | vyos-1x-ad6625d63f577dacc2760a6b2b658b2ceaeed119.tar.gz vyos-1x-ad6625d63f577dacc2760a6b2b658b2ceaeed119.zip |
Merge pull request #270 from thomas-mangin/2057-typo
ifconfig: T2057: fix finding section name from interface
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/ifconfig/register.py | 19 |
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 |