summaryrefslogtreecommitdiffstats
path: root/roles/lib_utils/src/ansible/yedit.py
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2017-01-13 12:37:30 -0500
committerKenny Woodson <kwoodson@redhat.com>2017-01-13 12:37:30 -0500
commit07331b47724dbb7cd6952c1a2af54275ace7726e (patch)
tree8ab8825399ee49ed363e9c8a2be1711eb6a3b1f2 /roles/lib_utils/src/ansible/yedit.py
parent1236604d2ddd835ab8559cbf632481a8a21e9bea (diff)
downloadopenshift-07331b47724dbb7cd6952c1a2af54275ace7726e.tar.gz
openshift-07331b47724dbb7cd6952c1a2af54275ace7726e.tar.bz2
openshift-07331b47724dbb7cd6952c1a2af54275ace7726e.tar.xz
openshift-07331b47724dbb7cd6952c1a2af54275ace7726e.zip
lib_openshift modules. This is the first one. oc_route.
Diffstat (limited to 'roles/lib_utils/src/ansible/yedit.py')
-rw-r--r--roles/lib_utils/src/ansible/yedit.py45
1 files changed, 1 insertions, 44 deletions
diff --git a/roles/lib_utils/src/ansible/yedit.py b/roles/lib_utils/src/ansible/yedit.py
index a80cd520c..efe034abf 100644
--- a/roles/lib_utils/src/ansible/yedit.py
+++ b/roles/lib_utils/src/ansible/yedit.py
@@ -1,49 +1,6 @@
# flake8: noqa
# pylint: skip-file
-
-def get_curr_value(invalue, val_type):
- '''return the current value'''
- if invalue is None:
- return None
-
- curr_value = invalue
- if val_type == 'yaml':
- curr_value = yaml.load(invalue)
- elif val_type == 'json':
- curr_value = json.loads(invalue)
-
- return curr_value
-
-
-def parse_value(inc_value, vtype=''):
- '''determine value type passed'''
- true_bools = ['y', 'Y', 'yes', 'Yes', 'YES', 'true', 'True', 'TRUE',
- 'on', 'On', 'ON', ]
- false_bools = ['n', 'N', 'no', 'No', 'NO', 'false', 'False', 'FALSE',
- 'off', 'Off', 'OFF']
-
- # It came in as a string but you didn't specify value_type as string
- # we will convert to bool if it matches any of the above cases
- if isinstance(inc_value, str) and 'bool' in vtype:
- if inc_value not in true_bools and inc_value not in false_bools:
- raise YeditException('Not a boolean type. str=[%s] vtype=[%s]'
- % (inc_value, vtype))
- elif isinstance(inc_value, bool) and 'str' in vtype:
- inc_value = str(inc_value)
-
- # If vtype is not str then go ahead and attempt to yaml load it.
- if isinstance(inc_value, str) and 'str' not in vtype:
- try:
- inc_value = yaml.load(inc_value)
- except Exception:
- raise YeditException('Could not determine type of incoming ' +
- 'value. value=[%s] vtype=[%s]'
- % (type(inc_value), vtype))
-
- return inc_value
-
-
# pylint: disable=too-many-branches
def main():
''' ansible oc module for secrets '''
@@ -75,7 +32,7 @@ def main():
rval = Yedit.run_ansible(module)
if 'failed' in rval and rval['failed']:
- module.fail_json(msg=rval['msg'])
+ module.fail_json(**rval)
module.exit_json(**rval)