diff options
author | Runar Borge <runar@borge.nu> | 2018-06-09 22:31:09 +0200 |
---|---|---|
committer | Runar Borge <runar@borge.nu> | 2018-06-09 22:31:09 +0200 |
commit | f3b4cfecbe48c75c88b9396f68c4b9fc2d7babc1 (patch) | |
tree | a043804da4a0b841c86455ceb8c9e8d5f73f7717 /src/completion/list_interfaces.py | |
parent | 06b807f9b898c6bef55c9c0888bf5fd1c96bc9bd (diff) | |
parent | e916c9a55ffdff970c1796829d1bee319802b353 (diff) | |
download | vyos-1x-f3b4cfecbe48c75c88b9396f68c4b9fc2d7babc1.tar.gz vyos-1x-f3b4cfecbe48c75c88b9396f68c4b9fc2d7babc1.zip |
Merge branch 'current' of git://github.com/vyos/vyos-1x into current
Diffstat (limited to 'src/completion/list_interfaces.py')
-rwxr-xr-x | src/completion/list_interfaces.py | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/completion/list_interfaces.py b/src/completion/list_interfaces.py index 59c9dffad..a4968c52f 100755 --- a/src/completion/list_interfaces.py +++ b/src/completion/list_interfaces.py @@ -1,8 +1,31 @@ #!/usr/bin/env python3 -import netifaces +import sys +import argparse -if __name__ == '__main__': - interfaces = netifaces.interfaces() +import vyos.interfaces - print(" ".join(interfaces)) + +parser = argparse.ArgumentParser() +group = parser.add_mutually_exclusive_group() +group.add_argument("-t", "--type", type=str, help="List interfaces of specific type") +group.add_argument("-b", "--broadcast", action="store_true", help="List all broadcast interfaces") + +args = parser.parse_args() + +if args.type: + try: + interfaces = vyos.interfaces.list_interfaces_of_type(args.type) + + except ValueError as e: + print(e, file=sys.stderr) + print("") +elif args.broadcast: + eth = vyos.interfaces.list_interfaces_of_type("ethernet") + bridge = vyos.interfaces.list_interfaces_of_type("bridge") + bond = vyos.interfaces.list_interfaces_of_type("bonding") + interfaces = eth + bridge + bond +else: + interfaces = vyos.interfaces.list_interfaces() + +print(" ".join(interfaces)) |