From d93efd69083c153c1586dd08d65f1d10769820b7 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Wed, 4 Mar 2020 19:10:49 +0100 Subject: vrf: T31: make 'show vrf' command behave like other 'show interface commands' - remove the additional depth for querying discrete VRF names - retrieve available VRF names from via from CLI rather then invoking an external script --- op-mode-definitions/show-vrf.xml | 22 ++++++++++------------ src/completion/list_vrf.py | 27 --------------------------- src/op_mode/show_vrf.py | 27 +++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 39 deletions(-) delete mode 100755 src/completion/list_vrf.py create mode 100755 src/op_mode/show_vrf.py diff --git a/op-mode-definitions/show-vrf.xml b/op-mode-definitions/show-vrf.xml index fb2fddd49..360153d8e 100644 --- a/op-mode-definitions/show-vrf.xml +++ b/op-mode-definitions/show-vrf.xml @@ -6,19 +6,17 @@ Show VRF information - ${vyos_completion_dir}/list_vrf.py -e - - - - Show VRF information for an interface - - - - - ${vyos_completion_dir}/list_vrf.py -e "$4" - - + ${vyos_op_scripts_dir}/show_vrf.py -e + + + Show information on specific VRF instance + + vrf name + + + ${vyos_op_scripts_dir}/show_vrf.py -e "$3" + diff --git a/src/completion/list_vrf.py b/src/completion/list_vrf.py deleted file mode 100755 index 210b3c9a4..000000000 --- a/src/completion/list_vrf.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python3 - -import argparse -import vyos.vrf - -parser = argparse.ArgumentParser() -group = parser.add_mutually_exclusive_group() -group.add_argument("-e", "--extensive", action="store_true", - help="provide detailed vrf informatio") -parser.add_argument('interface', metavar='I', type=str, nargs='?', - help='interface to display') - -args = parser.parse_args() - -if args.extensive: - print('{:16} {:7} {:17} {}'.format('interface', 'state', 'mac', 'flags')) - print('{:16} {:7} {:17} {}'.format('---------', '-----', '---', '-----')) - for vrf in vyos.vrf.list_vrfs(): - name = vrf['ifname'] - if args.interface and name != args.interface: - continue - state = vrf['operstate'].lower() - mac = vrf['address'].lower() - info = ','.join([_.lower() for _ in vrf['flags']]) - print(f'{name:16} {state:7} {mac:17} {info}') -else: - print(" ".join([vrf['ifname'] for vrf in vyos.vrf.list_vrfs()])) diff --git a/src/op_mode/show_vrf.py b/src/op_mode/show_vrf.py new file mode 100755 index 000000000..210b3c9a4 --- /dev/null +++ b/src/op_mode/show_vrf.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +import argparse +import vyos.vrf + +parser = argparse.ArgumentParser() +group = parser.add_mutually_exclusive_group() +group.add_argument("-e", "--extensive", action="store_true", + help="provide detailed vrf informatio") +parser.add_argument('interface', metavar='I', type=str, nargs='?', + help='interface to display') + +args = parser.parse_args() + +if args.extensive: + print('{:16} {:7} {:17} {}'.format('interface', 'state', 'mac', 'flags')) + print('{:16} {:7} {:17} {}'.format('---------', '-----', '---', '-----')) + for vrf in vyos.vrf.list_vrfs(): + name = vrf['ifname'] + if args.interface and name != args.interface: + continue + state = vrf['operstate'].lower() + mac = vrf['address'].lower() + info = ','.join([_.lower() for _ in vrf['flags']]) + print(f'{name:16} {state:7} {mac:17} {info}') +else: + print(" ".join([vrf['ifname'] for vrf in vyos.vrf.list_vrfs()])) -- cgit v1.2.3