oc_version.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # flake8: noqa
  2. # pylint: skip-file
  3. # pylint: disable=too-many-instance-attributes
  4. class OCVersion(OpenShiftCLI):
  5. ''' Class to wrap the oc command line tools '''
  6. # pylint allows 5
  7. # pylint: disable=too-many-arguments
  8. def __init__(self,
  9. config,
  10. debug):
  11. ''' Constructor for OCVersion '''
  12. super(OCVersion, self).__init__(None, config)
  13. self.debug = debug
  14. def get(self):
  15. '''get and return version information '''
  16. results = {}
  17. version_results = self._version()
  18. if version_results['returncode'] == 0:
  19. filtered_vers = Utils.filter_versions(version_results['results'])
  20. custom_vers = Utils.add_custom_versions(filtered_vers)
  21. results['returncode'] = version_results['returncode']
  22. results.update(filtered_vers)
  23. results.update(custom_vers)
  24. return results
  25. raise OpenShiftCLIError('Problem detecting openshift version.')
  26. @staticmethod
  27. def run_ansible(params):
  28. '''run the idempotent ansible code'''
  29. oc_version = OCVersion(params['kubeconfig'], params['debug'])
  30. if params['state'] == 'list':
  31. #pylint: disable=protected-access
  32. result = oc_version.get()
  33. return {'state': params['state'],
  34. 'results': result,
  35. 'changed': False}