diff options
author | Thomas Wiest <twiest@redhat.com> | 2017-01-29 16:01:49 -0500 |
---|---|---|
committer | Thomas Wiest <twiest@redhat.com> | 2017-01-30 13:49:26 -0500 |
commit | 58b40ef07005076357800daf47c83984adab2567 (patch) | |
tree | 278708655a2e7672ffd0487af3e179321a8ba7ce /roles/lib_openshift/library/oc_scale.py | |
parent | 8c7ccc601cab2f84a1fa3af9f4c1278dab96daf5 (diff) | |
download | openshift-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_scale.py')
-rw-r--r-- | roles/lib_openshift/library/oc_scale.py | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/roles/lib_openshift/library/oc_scale.py b/roles/lib_openshift/library/oc_scale.py index 705b05dc8..7eec9f81a 100644 --- a/roles/lib_openshift/library/oc_scale.py +++ b/roles/lib_openshift/library/oc_scale.py @@ -890,6 +890,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 ''' @@ -913,18 +925,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: |