summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/configdict.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py
index 4708d3b50..973fbdd8b 100644
--- a/python/vyos/configdict.py
+++ b/python/vyos/configdict.py
@@ -87,6 +87,19 @@ def retrieve_config(path_hash, base_path, config):
return config_hash
+def dict_merge(source, destination):
+ """ Merge two dictionaries. Only keys which are not present in destination
+ will be copied from source, anything else will be kept untouched. Function
+ will return a new dict which has the merged key/value pairs. """
+ from copy import deepcopy
+ tmp = deepcopy(destination)
+
+ for key, value in source.items():
+ if key not in tmp.keys():
+ tmp[key] = value
+
+ return tmp
+
def list_diff(first, second):
"""
Diff two dictionaries and return only unique items