Page MenuHomeVyOS Platform

Rewrite show vrf to new format
Closed, ResolvedPublicFEATURE REQUEST

Description

Rewrite show vrf to use vyos.opmode

Details

Version
1.4
Is it a breaking change?
Perfectly compatible
Issue type
Internal change (not visible to end users)

Event Timeline

Viacheslav changed the subtype of this task from "Bug" to "Feature Request".

PR https://github.com/vyos/vyos-1x/pull/1430

vyos@r14:~$ show vrf
Name    State    MAC address        Flags                     Interfaces
------  -------  -----------------  ------------------------  ---------------
foo     up       be:e3:5c:f1:54:99  noarp,master,up,lower_up  eth1.50,eth1.55
bar     up       1e:7c:94:da:e0:35  noarp,master,up,lower_up  n/a
vyos@r14:~$
Viacheslav changed the task status from Open to Needs testing.Jul 28 2022, 3:59 PM

PR https://github.com/vyos/vyos-1x/pull/1443

vyos@r14:~$ show vrf foo
Name    State    MAC address        Flags                     Interfaces
------  -------  -----------------  ------------------------  ------------
foo     up       aa:de:40:58:2e:dd  noarp,master,up,lower_up  eth1.2
vyos@r14:~$ 
vyos@r14:~$ 
vyos@r14:~$ 
vyos@r14:~$ /usr/libexec/vyos/op_mode/vrf.py show --name bar --raw
[
    {
        "ifname": "bar",
        "operstate": "UP",
        "address": "ce:c1:4f:e8:dc:9a",
        "flags": [
            "NOARP",
            "MASTER",
            "UP",
            "LOWER_UP"
        ]
    }
]
vyos@r14:~$
Viacheslav moved this task from Open to Finished on the VyOS 1.4 Sagitta board.

If vrf not configured:

vyos@r14:~$ /usr/libexec/vyos/op_mode/vrf.py show
Traceback (most recent call last):
  File "/usr/libexec/vyos/op_mode/vrf.py", line 89, in <module>
    res = vyos.opmode.run(sys.modules[__name__])
  File "/usr/lib/python3/dist-packages/vyos/opmode.py", line 118, in run
    res = func(**args)
  File "/usr/libexec/vyos/op_mode/vrf.py", line 84, in show
    return _get_formatted_output(vrf_data)
  File "/usr/libexec/vyos/op_mode/vrf.py", line 68, in _get_formatted_output
    state = vrf.get('operstate').lower()
AttributeError: 'NoneType' object has no attribute 'lower'
vyos@r14:~$