summaryrefslogtreecommitdiffstats
path: root/filter_plugins
diff options
context:
space:
mode:
authorJan Chaloupka <jchaloup@redhat.com>2017-02-14 09:40:36 +0100
committerGitHub <noreply@github.com>2017-02-14 09:40:36 +0100
commit7127518224d996e01a89db147434e404ebd35296 (patch)
tree6c3b1969e44e0e85e3f1935067f359fbeac017cd /filter_plugins
parent9c09ffbd4b1c2dc9593c6fb1f312172c538f2bec (diff)
parent8fd0bcfaa48b8fb62585dc96aa87741c58afe5cd (diff)
downloadopenshift-7127518224d996e01a89db147434e404ebd35296.tar.gz
openshift-7127518224d996e01a89db147434e404ebd35296.tar.bz2
openshift-7127518224d996e01a89db147434e404ebd35296.tar.xz
openshift-7127518224d996e01a89db147434e404ebd35296.zip
Merge pull request #3289 from mtnbikenc/upgrade-common
Modify playbooks to use oadm_manage_node module
Diffstat (limited to 'filter_plugins')
-rw-r--r--filter_plugins/oo_filters.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/filter_plugins/oo_filters.py b/filter_plugins/oo_filters.py
index c9390efe6..a833a5d93 100644
--- a/filter_plugins/oo_filters.py
+++ b/filter_plugins/oo_filters.py
@@ -242,6 +242,28 @@ def oo_combine_dict(data, in_joiner='=', out_joiner=' '):
return out_joiner.join([in_joiner.join([k, str(v)]) for k, v in data.items()])
+def oo_dict_to_list_of_dict(data, key_title='key', value_title='value'):
+ """Take a dict and arrange them as a list of dicts
+
+ Input data:
+ {'region': 'infra', 'test_k': 'test_v'}
+
+ Return data:
+ [{'key': 'region', 'value': 'infra'}, {'key': 'test_k', 'value': 'test_v'}]
+
+ Written for use of the oc_label module
+ """
+ if not isinstance(data, dict):
+ # pylint: disable=line-too-long
+ raise errors.AnsibleFilterError("|failed expects first param is a dict. Got %s. Type: %s" % (str(data), str(type(data))))
+
+ rval = []
+ for label in data.items():
+ rval.append({key_title: label[0], value_title: label[1]})
+
+ return rval
+
+
def oo_ami_selector(data, image_name):
""" This takes a list of amis and an image name and attempts to return
the latest ami.
@@ -951,6 +973,7 @@ class FilterModule(object):
"oo_ec2_volume_definition": oo_ec2_volume_definition,
"oo_combine_key_value": oo_combine_key_value,
"oo_combine_dict": oo_combine_dict,
+ "oo_dict_to_list_of_dict": oo_dict_to_list_of_dict,
"oo_split": oo_split,
"oo_filter_list": oo_filter_list,
"oo_parse_heat_stack_outputs": oo_parse_heat_stack_outputs,