summaryrefslogtreecommitdiffstats
path: root/roles/lib_openshift/library
diff options
context:
space:
mode:
authorKenny Woodson <kwoodson@redhat.com>2017-01-26 12:00:36 -0500
committerKenny Woodson <kwoodson@redhat.com>2017-01-26 14:20:19 -0500
commit853170d0e42ef23b8986e7b1a266232709f5b6f9 (patch)
tree86ea3d30326307cc0c33dfd69e5c7195787a3574 /roles/lib_openshift/library
parent0db4215a5570b550251af614e8e944b9f2db7094 (diff)
downloadopenshift-853170d0e42ef23b8986e7b1a266232709f5b6f9.tar.gz
openshift-853170d0e42ef23b8986e7b1a266232709f5b6f9.tar.bz2
openshift-853170d0e42ef23b8986e7b1a266232709f5b6f9.tar.xz
openshift-853170d0e42ef23b8986e7b1a266232709f5b6f9.zip
Added unit integration tests. Enhanced unit tests. Fixed an issue in openshift_cmd for namespace.
Diffstat (limited to 'roles/lib_openshift/library')
-rw-r--r--roles/lib_openshift/library/oadm_manage_node.py27
-rw-r--r--roles/lib_openshift/library/oc_edit.py2
-rw-r--r--roles/lib_openshift/library/oc_obj.py2
-rw-r--r--roles/lib_openshift/library/oc_route.py2
-rw-r--r--roles/lib_openshift/library/oc_secret.py2
-rw-r--r--roles/lib_openshift/library/oc_version.py2
6 files changed, 25 insertions, 12 deletions
diff --git a/roles/lib_openshift/library/oadm_manage_node.py b/roles/lib_openshift/library/oadm_manage_node.py
index f922ba570..dc605a574 100644
--- a/roles/lib_openshift/library/oadm_manage_node.py
+++ b/roles/lib_openshift/library/oadm_manage_node.py
@@ -920,7 +920,7 @@ class OpenShiftCLI(object):
if self.all_namespaces:
cmds.extend(['--all-namespaces'])
- elif self.namespace:
+ elif self.namespace is not None and self.namespace.lower() not in ['none', 'emtpy']: # E501
cmds.extend(['-n', self.namespace])
cmds.extend(cmd)
@@ -1358,9 +1358,11 @@ class ManageNode(OpenShiftCLI):
if isinstance(tmp_result, dict):
tmp_nodes.append(tmp_result)
continue
- tmp_nodes.extend(self.get_nodes(name))
+ tmp_nodes.extend(tmp_result)
nodes = tmp_nodes
+ # This is a short circuit based on the way we fetch nodes.
+ # If node is a dict/list then we've already fetched them.
for node in nodes:
if isinstance(node, dict) and node.has_key('returncode'):
return {'results': nodes, 'returncode': node['returncode']}
@@ -1370,10 +1372,21 @@ class ManageNode(OpenShiftCLI):
# node['schedulable'] == self.config.config_options['schedulable']['value']
if any([node['schedulable'] != self.config.config_options['schedulable']['value'] for node in nodes]):
- return self._schedulable(node=self.config.config_options['node']['value'],
- selector=self.config.config_options['selector']['value'],
- schedulable=self.config.config_options['schedulable']['value'],
- )
+ results = self._schedulable(node=self.config.config_options['node']['value'],
+ selector=self.config.config_options['selector']['value'],
+ schedulable=self.config.config_options['schedulable']['value'])
+
+ # 'NAME STATUS AGE\\nip-172-31-49-140.ec2.internal Ready 4h\\n' # E501
+ # normalize formatting with previous return objects
+ if results['results'].startswith('NAME'):
+ nodes = []
+ # removing header line and trailing new line character of node lines
+ for node_results in results['results'].split('\n')[1:-1]:
+ parts = node_results.split()
+ nodes.append({'name': parts[0], 'schedulable': 'Ready' == parts[1]})
+ results['nodes'] = nodes
+
+ return results
results = {}
results['returncode'] = 0
@@ -1435,7 +1448,7 @@ def main():
node=dict(default=None, type='list'),
selector=dict(default=None, type='str'),
pod_selector=dict(default=None, type='str'),
- schedulable=dict(default=False, type='bool'),
+ schedulable=dict(default=None, type='bool'),
list_pods=dict(default=False, type='bool'),
evacuate=dict(default=False, type='bool'),
dry_run=dict(default=False, type='bool'),
diff --git a/roles/lib_openshift/library/oc_edit.py b/roles/lib_openshift/library/oc_edit.py
index ad158e56a..064229d63 100644
--- a/roles/lib_openshift/library/oc_edit.py
+++ b/roles/lib_openshift/library/oc_edit.py
@@ -947,7 +947,7 @@ class OpenShiftCLI(object):
if self.all_namespaces:
cmds.extend(['--all-namespaces'])
- elif self.namespace:
+ elif self.namespace is not None and self.namespace.lower() not in ['none', 'emtpy']: # E501
cmds.extend(['-n', self.namespace])
cmds.extend(cmd)
diff --git a/roles/lib_openshift/library/oc_obj.py b/roles/lib_openshift/library/oc_obj.py
index b5ccfe700..132752f47 100644
--- a/roles/lib_openshift/library/oc_obj.py
+++ b/roles/lib_openshift/library/oc_obj.py
@@ -926,7 +926,7 @@ class OpenShiftCLI(object):
if self.all_namespaces:
cmds.extend(['--all-namespaces'])
- elif self.namespace:
+ elif self.namespace is not None and self.namespace.lower() not in ['none', 'emtpy']: # E501
cmds.extend(['-n', self.namespace])
cmds.extend(cmd)
diff --git a/roles/lib_openshift/library/oc_route.py b/roles/lib_openshift/library/oc_route.py
index fb51367fc..15b184083 100644
--- a/roles/lib_openshift/library/oc_route.py
+++ b/roles/lib_openshift/library/oc_route.py
@@ -951,7 +951,7 @@ class OpenShiftCLI(object):
if self.all_namespaces:
cmds.extend(['--all-namespaces'])
- elif self.namespace:
+ elif self.namespace is not None and self.namespace.lower() not in ['none', 'emtpy']: # E501
cmds.extend(['-n', self.namespace])
cmds.extend(cmd)
diff --git a/roles/lib_openshift/library/oc_secret.py b/roles/lib_openshift/library/oc_secret.py
index 69dcb314b..f5e994b27 100644
--- a/roles/lib_openshift/library/oc_secret.py
+++ b/roles/lib_openshift/library/oc_secret.py
@@ -947,7 +947,7 @@ class OpenShiftCLI(object):
if self.all_namespaces:
cmds.extend(['--all-namespaces'])
- elif self.namespace:
+ elif self.namespace is not None and self.namespace.lower() not in ['none', 'emtpy']: # E501
cmds.extend(['-n', self.namespace])
cmds.extend(cmd)
diff --git a/roles/lib_openshift/library/oc_version.py b/roles/lib_openshift/library/oc_version.py
index d74564352..dbd398c84 100644
--- a/roles/lib_openshift/library/oc_version.py
+++ b/roles/lib_openshift/library/oc_version.py
@@ -871,7 +871,7 @@ class OpenShiftCLI(object):
if self.all_namespaces:
cmds.extend(['--all-namespaces'])
- elif self.namespace:
+ elif self.namespace is not None and self.namespace.lower() not in ['none', 'emtpy']: # E501
cmds.extend(['-n', self.namespace])
cmds.extend(cmd)