X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=yardstick%2Fssh.py;h=6ddf327f213cd4ee8a850fcdfb200915b0c7daf5;hb=0a1d1ffb8134806e86a78c6b5577f7eff34e4400;hp=bb715e4b49e0d04c82dedcc094eaaed13673cc80;hpb=75ff03570c08093fbe5a2bb85856ec39752f900d;p=yardstick.git diff --git a/yardstick/ssh.py b/yardstick/ssh.py index bb715e4b4..6ddf327f2 100644 --- a/yardstick/ssh.py +++ b/yardstick/ssh.py @@ -64,6 +64,7 @@ Eventlet: """ from __future__ import absolute_import import os +import io import select import socket import time @@ -81,6 +82,14 @@ from yardstick.common.utils import try_int from yardstick.network_services.utils import provision_tool +def convert_key_to_str(key): + if not isinstance(key, (paramiko.RSAKey, paramiko.DSSKey)): + return key + k = io.StringIO() + key.write_private_key(k) + return k.getvalue() + + class SSHError(Exception): pass @@ -370,6 +379,12 @@ class SSH(object): with SCPClient(client.get_transport()) as scp: scp.put(files, remote_path, recursive) + def get(self, remote_path, local_path='/tmp/', recursive=True): + client = self._get_client() + + with SCPClient(client.get_transport()) as scp: + scp.get(remote_path, local_path, recursive) + # keep shell running in the background, e.g. screen def send_command(self, command): client = self._get_client()