diff options
author | UnicronNL <kim.sidney@gmail.com> | 2018-07-01 22:48:06 +0200 |
---|---|---|
committer | UnicronNL <kim.sidney@gmail.com> | 2018-07-01 22:48:06 +0200 |
commit | aaff68c0d55dc32f8972b9bde3239bb0923de140 (patch) | |
tree | 3d1d5aa18bd8d100e32d6ee2a4012f49f990117b /src/completion | |
parent | cf4738ddbff6858975ff5f2bb0d656453e563848 (diff) | |
download | vyos-salt-minion-aaff68c0d55dc32f8972b9bde3239bb0923de140.tar.gz vyos-salt-minion-aaff68c0d55dc32f8972b9bde3239bb0923de140.zip |
add vyos 1.x
Diffstat (limited to 'src/completion')
-rwxr-xr-x | src/completion/list_disks.sh | 5 | ||||
-rwxr-xr-x | src/completion/list_dumpable_interfaces.py | 14 | ||||
-rwxr-xr-x | src/completion/list_interfaces.py | 31 | ||||
-rwxr-xr-x | src/completion/list_raidset.sh | 3 |
4 files changed, 53 insertions, 0 deletions
diff --git a/src/completion/list_disks.sh b/src/completion/list_disks.sh new file mode 100755 index 0000000..f32e558 --- /dev/null +++ b/src/completion/list_disks.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +# Completion script used by show disks to collect physical disk + +awk 'NR > 2 && $4 !~ /[0-9]$/ { print $4 }' </proc/partitions diff --git a/src/completion/list_dumpable_interfaces.py b/src/completion/list_dumpable_interfaces.py new file mode 100755 index 0000000..53ee896 --- /dev/null +++ b/src/completion/list_dumpable_interfaces.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 + +# Extract the list of interfaces available for traffic dumps from tcpdump -D + +import re +import subprocess + +if __name__ == '__main__': + out = subprocess.check_output(['/usr/sbin/tcpdump', '-D']).decode().strip() + out = out.split("\n") + + intfs = " ".join(map(lambda s: re.search(r'\d+\.(\S+)\s', s).group(1), out)) + + print(intfs) diff --git a/src/completion/list_interfaces.py b/src/completion/list_interfaces.py new file mode 100755 index 0000000..a4968c5 --- /dev/null +++ b/src/completion/list_interfaces.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +import sys +import argparse + +import vyos.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)) diff --git a/src/completion/list_raidset.sh b/src/completion/list_raidset.sh new file mode 100755 index 0000000..9ff3523 --- /dev/null +++ b/src/completion/list_raidset.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo -n `cat /proc/partitions | grep md | awk '{ print $4 }'` |