diff options
author | Viacheslav <v.gletenko@vyos.io> | 2021-10-29 09:05:17 +0000 |
---|---|---|
committer | Viacheslav <v.gletenko@vyos.io> | 2021-10-29 09:05:17 +0000 |
commit | 558070cfde5157b3538b42085b9d0f775b3eb39d (patch) | |
tree | 7ef23b3a1eb1c4fa5ec598c0281223d4a0058b3c /src/op_mode | |
parent | ce969f3b746b36ec3aad25bc550601acc1901c03 (diff) | |
download | vyos-1x-558070cfde5157b3538b42085b9d0f775b3eb39d.tar.gz vyos-1x-558070cfde5157b3538b42085b9d0f775b3eb39d.zip |
bgp: T3745: Sorting output show vpn ipsec sa
Diffstat (limited to 'src/op_mode')
-rwxr-xr-x | src/op_mode/show_ipsec_sa.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/op_mode/show_ipsec_sa.py b/src/op_mode/show_ipsec_sa.py index 4e65daf1e..9955dead9 100755 --- a/src/op_mode/show_ipsec_sa.py +++ b/src/op_mode/show_ipsec_sa.py @@ -7,6 +7,13 @@ import subprocess import tabulate import hurry.filesize + +def convert(text): + return int(text) if text.isdigit() else text.lower() + +def alphanum_key(key): + return [convert(c) for c in re.split('([0-9]+)', str(key))] + def parse_conn_spec(s): try: # Example: ESTABLISHED 14 seconds ago, 10.0.0.2[foo]...10.0.0.1[10.0.0.1] @@ -85,6 +92,7 @@ for conn in connections: status_line = list(map(lambda x: "N/A" if x is None else x, status_line)) status_data.append(status_line) +status_data = sorted(status_data, key=alphanum_key) headers = ["Connection", "State", "Up", "Bytes In/Out", "Remote address", "Remote ID", "Proposal"] output = tabulate.tabulate(status_data, headers) print(output) |