aboutsummaryrefslogtreecommitdiffstats
path: root/opnfv/utils
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2016-11-17 23:03:44 +0100
committerJose Lausuch <jose.lausuch@ericsson.com>2017-01-30 08:56:48 +0000
commit1f6bc72cd6df04ee28e17e17c6e07571ec53ff4b (patch)
tree71337809e155f27c5618e10a8189aa9e4eaac673 /opnfv/utils
parent3e3c39c6ce40f5848959364f3800a579f52e2cfc (diff)
Create Apex Adapter
JIRA: RELENG-152 This implementation will help collect information from the deployment. For example: - overcloudrc file - files from the undercloud - files from the overcloud nodes (i.e. logs) Change-Id: I293837695a4b82e57b9fac6027fe8197d68b1f14 Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'opnfv/utils')
-rw-r--r--opnfv/utils/SSHUtils.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/opnfv/utils/SSHUtils.py b/opnfv/utils/SSHUtils.py
index 16e34c3..e0a830c 100644
--- a/opnfv/utils/SSHUtils.py
+++ b/opnfv/utils/SSHUtils.py
@@ -16,7 +16,11 @@ import os
logger = OPNFVLogger.Logger('SSHUtils').getLogger()
-def get_ssh_client(hostname, username, password=None, proxy=None):
+def get_ssh_client(hostname,
+ username,
+ password=None,
+ proxy=None,
+ pkey_file=None):
client = None
try:
if proxy is None:
@@ -26,14 +30,21 @@ def get_ssh_client(hostname, username, password=None, proxy=None):
client.configure_jump_host(proxy['ip'],
proxy['username'],
proxy['password'])
-
if client is None:
raise Exception('Could not connect to client')
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- client.connect(hostname,
- username=username,
- password=password)
+ if pkey_file is not None:
+ key = paramiko.RSAKey.from_private_key_file(pkey_file)
+ client.load_system_host_keys()
+ client.connect(hostname,
+ username=username,
+ pkey=key)
+ else:
+ client.connect(hostname,
+ username=username,
+ password=password)
+
return client
except Exception, e:
logger.error(e)
@@ -66,6 +77,7 @@ class ProxyHopClient(paramiko.SSHClient):
'''
Connect to a remote server using a proxy hop
'''
+
def __init__(self, *args, **kwargs):
self.logger = OPNFVLogger.Logger("ProxyHopClient").getLogger()
self.proxy_ssh = None