diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-09-04 12:37:23 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-09-04 12:39:27 +0200 |
commit | 4a2700aba8108bd7ef60821872ae1433b518a6d9 (patch) | |
tree | 7e112f843b5e1bba9e4b1337439c70bda1f68ce2 | |
parent | 5548dee213dc14b83322bfdcf32d089f5cb169eb (diff) | |
download | vyos-1x-4a2700aba8108bd7ef60821872ae1433b518a6d9.tar.gz vyos-1x-4a2700aba8108bd7ef60821872ae1433b518a6d9.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.
(cherry picked from commit 5e1f76d16332a917bfd99c6f2bffcd73e61d934d)
-rwxr-xr-x | src/op_mode/show_interfaces.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/op_mode/show_interfaces.py b/src/op_mode/show_interfaces.py index 17b52b5df..aef2d8060 100755 --- a/src/op_mode/show_interfaces.py +++ b/src/op_mode/show_interfaces.py @@ -52,11 +52,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 @@ -64,14 +65,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 |