From da02980779821862eed8966fd9e9258b807eb03d Mon Sep 17 00:00:00 2001 From: sarthurdev <965089+sarthurdev@users.noreply.github.com> Date: Mon, 5 Jul 2021 14:13:57 +0200 Subject: 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. --- python/vyos/util.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'python/vyos') 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. -- cgit v1.2.3