summaryrefslogtreecommitdiffstats
path: root/roles/lib_openshift/src/class/oc_version.py
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2017-01-19 12:24:52 -0500
committerKenny Woodson <kwoodson@redhat.com>2017-01-20 11:52:10 -0500
commit6218b9938b523c545a7610a3c77d6a19aea81e1a (patch)
treeb98fa3931aff326c10fec573c442e283d3d6f9bf /roles/lib_openshift/src/class/oc_version.py
parent836bd8115c7d9386b9f5d3d6cca41785853c16c7 (diff)
downloadopenshift-6218b9938b523c545a7610a3c77d6a19aea81e1a.tar.gz
openshift-6218b9938b523c545a7610a3c77d6a19aea81e1a.tar.bz2
openshift-6218b9938b523c545a7610a3c77d6a19aea81e1a.tar.xz
openshift-6218b9938b523c545a7610a3c77d6a19aea81e1a.zip
Adding version to lib_openshift
Diffstat (limited to 'roles/lib_openshift/src/class/oc_version.py')
-rw-r--r--roles/lib_openshift/src/class/oc_version.py47
1 files changed, 47 insertions, 0 deletions
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}