From 6218b9938b523c545a7610a3c77d6a19aea81e1a Mon Sep 17 00:00:00 2001 From: Kenny Woodson Date: Thu, 19 Jan 2017 12:24:52 -0500 Subject: Adding version to lib_openshift --- roles/lib_openshift/src/class/oc_route.py | 12 +++++--- roles/lib_openshift/src/class/oc_version.py | 47 +++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 roles/lib_openshift/src/class/oc_version.py (limited to 'roles/lib_openshift/src/class') diff --git a/roles/lib_openshift/src/class/oc_route.py b/roles/lib_openshift/src/class/oc_route.py index 05b1be409..42af2c01c 100644 --- a/roles/lib_openshift/src/class/oc_route.py +++ b/roles/lib_openshift/src/class/oc_route.py @@ -88,7 +88,9 @@ class OCRoute(OpenShiftCLI): files['key']['value'], params['host'], params['tls_termination'], - params['service_name']) + params['service_name'], + params['wildcard_policy'], + params['weight']) oc_route = OCRoute(rconfig, verbose=params['debug']) @@ -131,13 +133,13 @@ class OCRoute(OpenShiftCLI): api_rval = oc_route.create() if api_rval['returncode'] != 0: - return {'failed': True, 'results': api_rval, 'state': "present"} # noqa: E501 + return {'failed': True, 'msg': api_rval, 'state': "present"} # noqa: E501 # return the created object api_rval = oc_route.get() if api_rval['returncode'] != 0: - return {'failed': True, 'results': api_rval, 'state': "present"} # noqa: E501 + return {'failed': True, 'msg': api_rval, 'state': "present"} # noqa: E501 return {'changed': True, 'results': api_rval, 'state': "present"} # noqa: E501 @@ -152,13 +154,13 @@ class OCRoute(OpenShiftCLI): api_rval = oc_route.update() if api_rval['returncode'] != 0: - return {'failed': True, 'results': api_rval, 'state': "present"} # noqa: E501 + return {'failed': True, 'msg': api_rval, 'state': "present"} # noqa: E501 # return the created object api_rval = oc_route.get() if api_rval['returncode'] != 0: - return {'failed': True, 'results': api_rval, 'state': "present"} # noqa: E501 + return {'failed': True, 'msg': api_rval, 'state': "present"} # noqa: E501 return {'changed': True, 'results': api_rval, 'state': "present"} # noqa: E501 diff --git a/roles/lib_openshift/src/class/oc_version.py b/roles/lib_openshift/src/class/oc_version.py new file mode 100644 index 000000000..7f8c721d8 --- /dev/null +++ b/roles/lib_openshift/src/class/oc_version.py @@ -0,0 +1,47 @@ +# flake8: noqa +# pylint: skip-file + + +# pylint: disable=too-many-instance-attributes +class OCVersion(OpenShiftCLI): + ''' Class to wrap the oc command line tools ''' + # pylint allows 5 + # pylint: disable=too-many-arguments + def __init__(self, + config, + debug): + ''' Constructor for OCVersion ''' + super(OCVersion, self).__init__(None, config) + self.debug = debug + + def get(self): + '''get and return version information ''' + + results = {} + + version_results = self._version() + + if version_results['returncode'] == 0: + filtered_vers = Utils.filter_versions(version_results['results']) + custom_vers = Utils.add_custom_versions(filtered_vers) + + results['returncode'] = version_results['returncode'] + results.update(filtered_vers) + results.update(custom_vers) + + return results + + raise OpenShiftCLIError('Problem detecting openshift version.') + + @staticmethod + def run_ansible(params): + '''run the idempotent ansible code''' + oc_version = OCVersion(params['kubeconfig'], params['debug']) + + if params['state'] == 'list': + + #pylint: disable=protected-access + result = oc_version.get() + return {'state': params['state'], + 'results': result, + 'changed': False} -- cgit v1.2.3