diff options
author | Kenny Woodson <kwoodson@redhat.com> | 2017-04-10 16:06:21 -0400 |
---|---|---|
committer | Kenny Woodson <kwoodson@redhat.com> | 2017-04-19 15:05:33 -0400 |
commit | 6473004b66fc3ae3b185e38b0d167307a6497d1a (patch) | |
tree | 538fdc11eed9efc05cac274baea89608087c4880 /roles/lib_openshift/src | |
parent | 14dbd7c24df84a0b13a79ce1901de221548442f5 (diff) | |
download | openshift-6473004b66fc3ae3b185e38b0d167307a6497d1a.tar.gz openshift-6473004b66fc3ae3b185e38b0d167307a6497d1a.tar.bz2 openshift-6473004b66fc3ae3b185e38b0d167307a6497d1a.tar.xz openshift-6473004b66fc3ae3b185e38b0d167307a6497d1a.zip |
Adding module calls instead of command for idempotency.
Diffstat (limited to 'roles/lib_openshift/src')
-rw-r--r-- | roles/lib_openshift/src/class/oc_adm_policy_user.py | 2 | ||||
-rw-r--r-- | roles/lib_openshift/src/class/oc_clusterrole.py | 6 | ||||
-rw-r--r-- | roles/lib_openshift/src/lib/rule.py | 8 |
3 files changed, 10 insertions, 6 deletions
diff --git a/roles/lib_openshift/src/class/oc_adm_policy_user.py b/roles/lib_openshift/src/class/oc_adm_policy_user.py index 88fcc1ddc..37a685ebb 100644 --- a/roles/lib_openshift/src/class/oc_adm_policy_user.py +++ b/roles/lib_openshift/src/class/oc_adm_policy_user.py @@ -46,7 +46,7 @@ class PolicyUser(OpenShiftCLI): @property def policybindings(self): if self._policy_bindings is None: - results = self._get('clusterpolicybindings', None) + results = self._get('policybindings', None) if results['returncode'] != 0: raise OpenShiftCLIError('Could not retrieve policybindings') self._policy_bindings = results['results'][0]['items'][0] diff --git a/roles/lib_openshift/src/class/oc_clusterrole.py b/roles/lib_openshift/src/class/oc_clusterrole.py index 1d3d977db..ae6795446 100644 --- a/roles/lib_openshift/src/class/oc_clusterrole.py +++ b/roles/lib_openshift/src/class/oc_clusterrole.py @@ -22,7 +22,7 @@ class OCClusterRole(OpenShiftCLI): @property def clusterrole(self): ''' property for clusterrole''' - if not self._clusterrole: + if self._clusterrole is None: self.get() return self._clusterrole @@ -58,6 +58,7 @@ class OCClusterRole(OpenShiftCLI): elif 'clusterrole "{}" not found'.format(self.name) in result['stderr']: result['returncode'] = 0 + self.clusterrole = None return result @@ -127,6 +128,9 @@ class OCClusterRole(OpenShiftCLI): # Create it here api_rval = oc_clusterrole.create() + if api_rval['returncode'] != 0: + return {'failed': True, 'msg': api_rval} + # return the created object api_rval = oc_clusterrole.get() diff --git a/roles/lib_openshift/src/lib/rule.py b/roles/lib_openshift/src/lib/rule.py index 4590dcf90..fe5ed9723 100644 --- a/roles/lib_openshift/src/lib/rule.py +++ b/roles/lib_openshift/src/lib/rule.py @@ -136,9 +136,9 @@ class Rule(object): results = [] for rule in inc_rules: - results.append(Rule(rule['apiGroups'], - rule['attributeRestrictions'], - rule['resources'], - rule['verbs'])) + results.append(Rule(rule.get('apiGroups', ['']), + rule.get('attributeRestrictions', None), + rule.get('resources', []), + rule.get('verbs', []))) return results |