summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorsarthurdev <965089+sarthurdev@users.noreply.github.com>2021-07-05 14:13:57 +0200
committersarthurdev <965089+sarthurdev@users.noreply.github.com>2021-07-05 16:23:31 +0200
commitda02980779821862eed8966fd9e9258b807eb03d (patch)
treed3b8205bcaa1f881400bcf082a61a3561db02b58 /python
parent20c4d06c717cd34e099cef942f86776b9b838e58 (diff)
downloadvyos-1x-da02980779821862eed8966fd9e9258b807eb03d.tar.gz
vyos-1x-da02980779821862eed8966fd9e9258b807eb03d.zip
pki: ipsec: T3642: Fix issue with '.' being present in tag nodes, adds new vyos.util method `dict_search_args` to allow for dot characters in keys.
Diffstat (limited to 'python')
-rw-r--r--python/vyos/util.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py
index 8247ccb2d..c64b477ef 100644
--- a/python/vyos/util.py
+++ b/python/vyos/util.py
@@ -705,6 +705,19 @@ def dict_search(path, my_dict):
c = c.get(p, {})
return c.get(parts[-1], None)
+def dict_search_args(dict_object, *path):
+ # Traverse dictionary using variable arguments
+ # Added due to above function not allowing for '.' in the key names
+ # Example: dict_search_args(some_dict, 'key', 'subkey', 'subsubkey', ...)
+ if not isinstance(dict_object, dict) or not path:
+ return None
+
+ for item in path:
+ if item not in dict_object:
+ return None
+ dict_object = dict_object[item]
+ return dict_object
+
def get_interface_config(interface):
""" Returns the used encapsulation protocol for given interface.
If interface does not exist, None is returned.