summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRex Lee <limingjiang@huawei.com>2016-12-13 07:38:03 +0000
committerGerrit Code Review <gerrit@opnfv.org>2016-12-13 07:38:03 +0000
commit0be6ce88fcf1d39b55c6bc92fc47f506013aa694 (patch)
tree8d84b5924d81cd4ebd7d8ffced87eb570d67892b
parent9297d61e95de1d03f3bd98e201f8bd29beed0982 (diff)
parent9c9704b6d2658bc6288aafeaeb8af9581f7fc053 (diff)
Merge "ssh.py: add flag to request for a pseudo terminal (pty) for ssh connection"
-rw-r--r--yardstick/ssh.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/yardstick/ssh.py b/yardstick/ssh.py
index 46d53b7d2..2ba6de92e 100644
--- a/yardstick/ssh.py
+++ b/yardstick/ssh.py
@@ -157,7 +157,7 @@ class SSH(object):
def run(self, cmd, stdin=None, stdout=None, stderr=None,
raise_on_error=True, timeout=3600,
- keep_stdin_open=False):
+ keep_stdin_open=False, pty=False):
"""Execute specified command on the server.
:param cmd: Command to be executed.
@@ -171,6 +171,10 @@ class SSH(object):
Default 1 hour. No timeout if set to 0.
:param keep_stdin_open: don't close stdin on empty reads
:type keep_stdin_open: bool
+ :param pty: Request a pseudo terminal for this connection.
+ This allows passing control characters.
+ Default False.
+ :type pty: bool
"""
client = self._get_client()
@@ -181,14 +185,16 @@ class SSH(object):
return self._run(client, cmd, stdin=stdin, stdout=stdout,
stderr=stderr, raise_on_error=raise_on_error,
timeout=timeout,
- keep_stdin_open=keep_stdin_open)
+ keep_stdin_open=keep_stdin_open, pty=pty)
def _run(self, client, cmd, stdin=None, stdout=None, stderr=None,
raise_on_error=True, timeout=3600,
- keep_stdin_open=False):
+ keep_stdin_open=False, pty=False):
transport = client.get_transport()
session = transport.open_session()
+ if pty:
+ session.get_pty()
session.exec_command(cmd)
start_time = time.time()