summaryrefslogtreecommitdiffstats
path: root/yardstick/ssh.py
diff options
context:
space:
mode:
authorDeepak S <deepak.s@linux.intel.com>2016-12-08 13:57:13 +0530
committerDeepak S <deepak.s@linux.intel.com>2016-12-08 16:51:31 +0000
commit9c9704b6d2658bc6288aafeaeb8af9581f7fc053 (patch)
tree714eb4ca515608bb8abb99c80aac7e8fd924d51e /yardstick/ssh.py
parent6d8123f78a63292cf8be65bf7a347a5867bd5220 (diff)
ssh.py: add flag to request for a pseudo terminal (pty) for ssh connection
For some VNFs we may want to send periodic commands, for example to print statistics etc. When you open a SSH connection, request a pseudo terminal (pty) which allows passing of control characters to the connection. JIRA: YARDSTICK-453 Change-Id: Ibfd4164e745f005d0e29f6efdc63076e1e220b60 Signed-off-by: Deepak S <deepak.s@linux.intel.com>
Diffstat (limited to 'yardstick/ssh.py')
-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()