summaryrefslogtreecommitdiffstats
path: root/filter_plugins
diff options
context:
space:
mode:
authorAndrew Butcher <abutcher@redhat.com>2016-04-08 16:14:49 -0400
committerAndrew Butcher <abutcher@redhat.com>2016-04-08 16:14:49 -0400
commit8591af8679e13374d9f13d8867679adee45a7d0d (patch)
tree34c8f83832193f407a26a5e194977a623a1a6d26 /filter_plugins
parentba4debd2aa9c808cd982030d3589443e87bb900e (diff)
downloadopenshift-8591af8679e13374d9f13d8867679adee45a7d0d.tar.gz
openshift-8591af8679e13374d9f13d8867679adee45a7d0d.tar.bz2
openshift-8591af8679e13374d9f13d8867679adee45a7d0d.tar.xz
openshift-8591af8679e13374d9f13d8867679adee45a7d0d.zip
Merge openshift_env hostvars.
Diffstat (limited to 'filter_plugins')
-rw-r--r--filter_plugins/oo_filters.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py
index cd67b69a5..e9aacb187 100644
--- a/filter_plugins/oo_filters.py
+++ b/filter_plugins/oo_filters.py
@@ -57,6 +57,19 @@ class FilterModule(object):
return [item for sublist in data for item in sublist]
@staticmethod
+ def oo_merge_dicts(first_dict, second_dict):
+ """ Merge two dictionaries where second_dict values take precedence.
+ Ex: first_dict={'a': 1, 'b': 2}
+ second_dict={'b': 3, 'c': 4}
+ returns {'a': 1, 'b': 3, 'c': 4}
+ """
+ if not isinstance(first_dict, dict) or not isinstance(second_dict, dict):
+ raise errors.AnsibleFilterError("|failed expects to merge two dicts")
+ merged = first_dict.copy()
+ merged.update(second_dict)
+ return merged
+
+ @staticmethod
def oo_collect(data, attribute=None, filters=None):
""" This takes a list of dict and collects all attributes specified into a
list. If filter is specified then we will include all items that
@@ -755,4 +768,5 @@ class FilterModule(object):
"oo_pods_match_component": self.oo_pods_match_component,
"oo_get_hosts_from_hostvars": self.oo_get_hosts_from_hostvars,
"oo_image_tag_to_rpm_version": self.oo_image_tag_to_rpm_version,
+ "oo_merge_dicts": self.oo_merge_dicts
}