summaryrefslogtreecommitdiffstats
path: root/roles/lib_openshift/library/oc_clusterrole.py
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2017-04-10 16:06:21 -0400
committerKenny Woodson <kwoodson@redhat.com>2017-04-19 15:05:33 -0400
commit6473004b66fc3ae3b185e38b0d167307a6497d1a (patch)
tree538fdc11eed9efc05cac274baea89608087c4880 /roles/lib_openshift/library/oc_clusterrole.py
parent14dbd7c24df84a0b13a79ce1901de221548442f5 (diff)
downloadopenshift-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/library/oc_clusterrole.py')
-rw-r--r--roles/lib_openshift/library/oc_clusterrole.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/roles/lib_openshift/library/oc_clusterrole.py b/roles/lib_openshift/library/oc_clusterrole.py
index a34ce351e..e2cbcfb81 100644
--- a/roles/lib_openshift/library/oc_clusterrole.py
+++ b/roles/lib_openshift/library/oc_clusterrole.py
@@ -1531,10 +1531,10 @@ 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
@@ -1633,7 +1633,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
@@ -1669,6 +1669,7 @@ class OCClusterRole(OpenShiftCLI):
elif 'clusterrole "{}" not found'.format(self.name) in result['stderr']:
result['returncode'] = 0
+ self.clusterrole = None
return result
@@ -1738,6 +1739,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()