Merge pull request #35639 from joscollin/wip-fix-sh-as-in-teuthology

qa/tasks: make sh() in vstart_runner.py identical with teuthology.orchestra.remote.sh

Reviewed-by: Kyr Shatskyy <kyrylo.shatskyy@suse.com>
Reviewed-by: Rishabh Dave <ridave@redhat.com>
This commit is contained in:
Jos Collin 2020-07-02 11:56:19 +05:30 committed by GitHub
commit e4673f4778
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -430,7 +430,8 @@ class LocalRemote(object):
return proc
# XXX: for compatibility keep this method same teuthology.orchestra.remote.sh
# XXX: for compatibility keep this method same as teuthology.orchestra.remote.sh
# BytesIO is being used just to keep things identical
def sh(self, script, **kwargs):
"""
Shortcut for run method.
@ -439,13 +440,18 @@ class LocalRemote(object):
my_name = remote.sh('whoami')
remote_date = remote.sh('date')
"""
from io import BytesIO
if 'stdout' not in kwargs:
kwargs['stdout'] = StringIO()
kwargs['stdout'] = BytesIO()
if 'args' not in kwargs:
kwargs['args'] = script
proc = self.run(**kwargs)
return proc.stdout.getvalue()
out = proc.stdout.getvalue()
if isinstance(out, bytes):
return out.decode()
else:
return out
class LocalDaemon(object):
def __init__(self, daemon_type, daemon_id):