diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-08-14 19:01:53 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-08-14 20:23:14 +0200 |
commit | 2cd7e709c7961bd673be737ad197465aab143137 (patch) | |
tree | ccbbfca03dbcb4820995478ff56e3b664f1bce3e | |
parent | 3ee6549871626e4dad17b28894f0937a72b892fa (diff) | |
download | vyos-1x-2cd7e709c7961bd673be737ad197465aab143137.tar.gz vyos-1x-2cd7e709c7961bd673be737ad197465aab143137.zip |
op-mode: ipsec: T3745: "show vpn ipse sa" improve sorting
(cherry picked from commit 1229665d353a070e14ee9cceafbfdb107d669745)
-rwxr-xr-x | src/op_mode/show_ipsec_sa.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/op_mode/show_ipsec_sa.py b/src/op_mode/show_ipsec_sa.py index 645a0571d..8b8f11947 100755 --- a/src/op_mode/show_ipsec_sa.py +++ b/src/op_mode/show_ipsec_sa.py @@ -23,6 +23,11 @@ import hurry.filesize import vyos.util +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))] try: session = vici.Session() @@ -109,6 +114,6 @@ for sa in sas: sa_data.append(data) headers = ["Connection", "State", "Uptime", "Bytes In/Out", "Packets In/Out", "Remote address", "Remote ID", "Proposal"] -sa_data = sorted(sa_data, key=lambda peer: peer[0]) +sa_data = sorted(sa_data, key=alphanum_key) output = tabulate.tabulate(sa_data, headers) print(output) |