diff options
author | sarthurdev <965089+sarthurdev@users.noreply.github.com> | 2021-07-05 14:13:57 +0200 |
---|---|---|
committer | sarthurdev <965089+sarthurdev@users.noreply.github.com> | 2021-07-05 16:23:31 +0200 |
commit | da02980779821862eed8966fd9e9258b807eb03d (patch) | |
tree | d3b8205bcaa1f881400bcf082a61a3561db02b58 /python/vyos/util.py | |
parent | 20c4d06c717cd34e099cef942f86776b9b838e58 (diff) | |
download | vyos-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/vyos/util.py')
-rw-r--r-- | python/vyos/util.py | 13 |
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. |