Page MenuHomeVyOS Platform

Rewrite show vrf to new format
Closed, ResolvedPublicFEATURE REQUEST

Description

Rewrite show vrf to use vyos.opmode

Details

Difficulty level
Normal (likely a few hours)
Version
1.4
Why the issue appeared?
Will be filled on close
Is it a breaking change?
Perfectly compatible
Issue type
Internal change (not visible to end users)

Related Objects

StatusSubtypeAssignedTask
OpenFEATURE REQUESTNone
ResolvedFEATURE REQUESTViacheslav

Event Timeline

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

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

[email protected]:~$ 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
[email protected]:~$
Viacheslav changed the task status from Open to Needs testing.Thu, Jul 28, 3:59 PM

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

[email protected]:~$ show vrf foo
Name    State    MAC address        Flags                     Interfaces
------  -------  -----------------  ------------------------  ------------
foo     up       aa:de:40:58:2e:dd  noarp,master,up,lower_up  eth1.2
[email protected]:~$ 
[email protected]:~$ 
[email protected]:~$ 
[email protected]:~$ /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"
        ]
    }
]
[email protected]:~$
Viacheslav moved this task from Need Triage to Finished on the VyOS 1.4 Sagitta board.

If vrf not configured:

[email protected]:~$ /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'
[email protected]:~$