summaryrefslogtreecommitdiffstats
path: root/roles/lib_openshift/library/oc_route.py
diff options
context:
space:
mode:
authorThomas Wiest <twiest@redhat.com>2017-01-29 16:01:49 -0500
committerThomas Wiest <twiest@redhat.com>2017-01-30 13:49:26 -0500
commit58b40ef07005076357800daf47c83984adab2567 (patch)
tree278708655a2e7672ffd0487af3e179321a8ba7ce /roles/lib_openshift/library/oc_route.py
parent8c7ccc601cab2f84a1fa3af9f4c1278dab96daf5 (diff)
downloadopenshift-58b40ef07005076357800daf47c83984adab2567.tar.gz
openshift-58b40ef07005076357800daf47c83984adab2567.tar.bz2
openshift-58b40ef07005076357800daf47c83984adab2567.tar.xz
openshift-58b40ef07005076357800daf47c83984adab2567.zip
Added oc_serviceaccount to lib_openshift.
Diffstat (limited to 'roles/lib_openshift/library/oc_route.py')
-rw-r--r--roles/lib_openshift/library/oc_route.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/roles/lib_openshift/library/oc_route.py b/roles/lib_openshift/library/oc_route.py
index 15b184083..0419c7bc7 100644
--- a/roles/lib_openshift/library/oc_route.py
+++ b/roles/lib_openshift/library/oc_route.py
@@ -940,6 +940,18 @@ class OpenShiftCLI(object):
cmd.append('--confirm')
return self.openshift_cmd(cmd)
+ def _run(self, cmds, input_data):
+ ''' Actually executes the command. This makes mocking easier. '''
+ proc = subprocess.Popen(cmds,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ env={'KUBECONFIG': self.kubeconfig})
+
+ stdout, stderr = proc.communicate(input_data)
+
+ return proc.returncode, stdout, stderr
+
# pylint: disable=too-many-arguments,too-many-branches
def openshift_cmd(self, cmd, oadm=False, output=False, output_type='json', input_data=None):
'''Base command for oc '''
@@ -963,18 +975,13 @@ class OpenShiftCLI(object):
if self.verbose:
print(' '.join(cmds))
- proc = subprocess.Popen(cmds,
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- env={'KUBECONFIG': self.kubeconfig})
+ returncode, stdout, stderr = self._run(cmds, input_data)
- stdout, stderr = proc.communicate(input_data)
- rval = {"returncode": proc.returncode,
+ rval = {"returncode": returncode,
"results": results,
"cmd": ' '.join(cmds)}
- if proc.returncode == 0:
+ if returncode == 0:
if output:
if output_type == 'json':
try: