summaryrefslogtreecommitdiff
path: root/python/vyos/util.py
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2022-11-21 10:55:46 +0000
committerViacheslav Hletenko <v.gletenko@vyos.io>2022-11-21 10:55:46 +0000
commit997215f54a95c5eeab891ba241672bf5498abb80 (patch)
tree364875032504cc36c6734ac8ca75ca69e25a8216 /python/vyos/util.py
parent6d90375db4dd0c9beb2815e8ceae2d6214465f99 (diff)
downloadvyos-1x-997215f54a95c5eeab891ba241672bf5498abb80.tar.gz
vyos-1x-997215f54a95c5eeab891ba241672bf5498abb80.zip
T4812: Add op-mode Show vpn ipsec connections
Add op-mode CLI "show vpn ipsec connections" Add the ability to show all configured connections/tunnels and their states.
Diffstat (limited to 'python/vyos/util.py')
-rw-r--r--python/vyos/util.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py
index 1c4102e90..67ec3ecc6 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -699,6 +699,32 @@ def dict_search(path, dict_object):
c = c.get(p, {})
return c.get(parts[-1], None)
+def convert_data(data):
+ """Convert multiple types of data to types usable in CLI
+
+ Args:
+ data (str | bytes | list | OrderedDict): input data
+
+ Returns:
+ str | list | dict: converted data
+ """
+ from collections import OrderedDict
+
+ if isinstance(data, str):
+ return data
+ if isinstance(data, bytes):
+ return data.decode()
+ if isinstance(data, list):
+ list_tmp = []
+ for item in data:
+ list_tmp.append(convert_data(item))
+ return list_tmp
+ if isinstance(data, OrderedDict):
+ dict_tmp = {}
+ for key, value in data.items():
+ dict_tmp[key] = convert_data(value)
+ return dict_tmp
+
def get_bridge_fdb(interface):
""" Returns the forwarding database entries for a given interface """
if not os.path.exists(f'/sys/class/net/{interface}'):