summaryrefslogtreecommitdiff
path: root/src/op_mode/show_interfaces.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-09-04 12:37:23 +0200
committerChristian Poessinger <christian@poessinger.com>2021-09-04 12:37:23 +0200
commit5e1f76d16332a917bfd99c6f2bffcd73e61d934d (patch)
tree7176ab582e5a06ede5dce24f5a6205e1a7a31f72 /src/op_mode/show_interfaces.py
parent27e53fbcd843c3aad27db9e97f9060ae6dfcc5ee (diff)
downloadvyos-1x-5e1f76d16332a917bfd99c6f2bffcd73e61d934d.tar.gz
vyos-1x-5e1f76d16332a917bfd99c6f2bffcd73e61d934d.zip
op-mode: T3619: bugfix "show interfaces X detail"
Commit 27e53fbc ("op-mode: T3619: bugfix "show interfaces" for VLANs") fixed the op-mode command for the "show interfaces" operation, but if a user was interested in all the ethernet or bridge interfaces, the command "show interfaces <type> detail" did not yield any output. The filtered_interfaces() function was further generalized to only operate on base components and call itself recusively if required.
Diffstat (limited to 'src/op_mode/show_interfaces.py')
-rwxr-xr-xsrc/op_mode/show_interfaces.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/op_mode/show_interfaces.py b/src/op_mode/show_interfaces.py
index 1707d8669..3d50eb938 100755
--- a/src/op_mode/show_interfaces.py
+++ b/src/op_mode/show_interfaces.py
@@ -61,11 +61,12 @@ def filtered_interfaces(ifnames, iftypes, vif, vrrp):
ifnames: a list of interfaces names to consider, empty do not filter
return an instance of the interface class
"""
- allnames = Section.interfaces()
+ if isinstance(iftypes, list):
+ for iftype in iftypes:
+ yield from filtered_interfaces(ifnames, iftype, vif, vrrp)
- vrrp_interfaces = VRRP.active_interfaces() if vrrp else []
-
- for ifname in allnames:
+ for ifname in Section.interfaces(iftypes):
+ # Bail out early if interface name not part of our search list
if ifnames and ifname not in ifnames:
continue
@@ -73,14 +74,14 @@ def filtered_interfaces(ifnames, iftypes, vif, vrrp):
# generic base class which exposes all the data via a common API
interface = Interface(ifname, create=False, debug=False)
- if iftypes and interface.definition['section'] not in iftypes:
- continue
-
+ # VLAN interfaces have a '.' in their name by convention
if vif and not '.' in ifname:
continue
- if vrrp and ifname not in vrrp_interfaces:
- continue
+ if vrrp:
+ vrrp_interfaces = VRRP.active_interfaces()
+ if ifname not in vrrp_interfaces:
+ continue
yield interface