summaryrefslogtreecommitdiff
path: root/src/completion/list_vrf.py
diff options
context:
space:
mode:
authorThomas Mangin <thomas.mangin@exa.net.uk>2020-03-03 20:01:56 +0100
committerChristian Poessinger <christian@poessinger.com>2020-03-04 21:43:59 +0100
commit665d1c5bdb24aa0aef79405dc2f2962b930fb9b3 (patch)
tree467499a4ce63308ca6d1e349b13f1e807ba4703e /src/completion/list_vrf.py
parentdac5ad318b00853591121078bce5c849db23c810 (diff)
downloadvyos-1x-665d1c5bdb24aa0aef79405dc2f2962b930fb9b3.tar.gz
vyos-1x-665d1c5bdb24aa0aef79405dc2f2962b930fb9b3.zip
vrf: T31: initial support for a VRF backend in XML/Python
This is a work in progress to complete T31 whoever thought it was less than 1 hour of work was ..... optimistic. Only VRF vreation and show is supported right now. No interface can be bound to any one VRF.
Diffstat (limited to 'src/completion/list_vrf.py')
-rwxr-xr-xsrc/completion/list_vrf.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/completion/list_vrf.py b/src/completion/list_vrf.py
new file mode 100755
index 000000000..210b3c9a4
--- /dev/null
+++ b/src/completion/list_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()]))