summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2021-10-29 16:16:46 +0700
committerGitHub <noreply@github.com>2021-10-29 16:16:46 +0700
commit4f4200f542c33e14d298cbdb2d12fe4f804188d9 (patch)
tree7ef23b3a1eb1c4fa5ec598c0281223d4a0058b3c /src
parentce969f3b746b36ec3aad25bc550601acc1901c03 (diff)
parent558070cfde5157b3538b42085b9d0f775b3eb39d (diff)
downloadvyos-1x-4f4200f542c33e14d298cbdb2d12fe4f804188d9.tar.gz
vyos-1x-4f4200f542c33e14d298cbdb2d12fe4f804188d9.zip
Merge pull request #1054 from sever-sever/T3745-crux
bgp: T3745: Sorting output show vpn ipsec sa
Diffstat (limited to 'src')
-rwxr-xr-xsrc/op_mode/show_ipsec_sa.py8
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)