From d2786d8aae95cb691a103907224d4a178e221a8b Mon Sep 17 00:00:00 2001 From: Aleksandr Dobdin Date: Thu, 29 Sep 2016 15:18:49 +0000 Subject: [PATCH] add: login parameter for ssh Change-Id: I4f770d8d48e34fa98bf60d43eba8086db2ece9f9 Fix: issue 61 --- timmy/conf.py | 2 +- timmy/nodes.py | 2 ++ timmy/tools.py | 16 ++++++++++------ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/timmy/conf.py b/timmy/conf.py index 7ba0bd9..a84455c 100644 --- a/timmy/conf.py +++ b/timmy/conf.py @@ -29,7 +29,7 @@ def load_conf(filename): conf['soft_filter'] = {} conf['ssh_opts'] = ['-oConnectTimeout=2', '-oStrictHostKeyChecking=no', '-oUserKnownHostsFile=/dev/null', '-oLogLevel=error', - '-lroot', '-oBatchMode=yes'] + '-oBatchMode=yes', '-oUser=root'] conf['env_vars'] = ['OPENRC=/root/openrc', 'LC_ALL="C"', 'LANG="C"'] conf['fuel_ip'] = '127.0.0.1' conf['fuel_api_user'] = 'admin' diff --git a/timmy/nodes.py b/timmy/nodes.py index 2db81ec..280992f 100644 --- a/timmy/nodes.py +++ b/timmy/nodes.py @@ -396,6 +396,7 @@ class Node(object): for f in self.files: outs, errs, code = tools.get_file_scp(ip=self.ip, file=f, + ssh_opts=self.ssh_opts, ddir=ddir, recursive=True) self.check_code(code, 'get_files', 'tools.get_file_scp', errs) @@ -406,6 +407,7 @@ class Node(object): outs, errs, code = tools.put_file_scp(ip=self.ip, file=f[0], dest=f[1], + ssh_opts=self.ssh_opts, recursive=True) self.check_code(code, 'put_files', 'tools.put_file_scp', errs) diff --git a/timmy/tools.py b/timmy/tools.py index 39dfb1e..71f1e1a 100644 --- a/timmy/tools.py +++ b/timmy/tools.py @@ -327,20 +327,24 @@ def get_files_rsync(ip, data, ssh_opts, dpath, timeout=15): return launch_cmd(cmd, timeout, input=data) -def get_file_scp(ip, file, ddir, timeout=600, recursive=False): +def get_file_scp(ip, file, ddir, ssh_opts, timeout=600, recursive=False): + if type(ssh_opts) is list: + ssh_opts = ' '.join(ssh_opts) dest = os.path.split(os.path.normpath(file).lstrip(os.path.sep))[0] ddir = os.path.join(os.path.normpath(ddir), dest) mdir(ddir) r = '-r ' if recursive else '' - cmd = ("timeout '%s' scp -oStrictHostKeyChecking=no -q %s'%s':'%s' '%s'" % - (timeout, r, ip, file, ddir)) + cmd = ("timeout '%s' scp %s -p -q %s'%s':'%s' '%s'" % + (timeout, ssh_opts, r, ip, file, ddir)) return launch_cmd(cmd, timeout) -def put_file_scp(ip, file, dest, timeout=600, recursive=True): +def put_file_scp(ip, file, dest, ssh_opts, timeout=600, recursive=True): + if type(ssh_opts) is list: + ssh_opts = ' '.join(ssh_opts) r = '-r ' if recursive else '' - cmd = ("timeout '%s' scp -oStrictHostKeyChecking=no -q %s'%s' '%s':'%s'" % - (timeout, r, file, ip, dest)) + cmd = ("timeout '%s' scp %s -p -q %s'%s' '%s':'%s'" % + (timeout, ssh_opts, r, file, ip, dest)) return launch_cmd(cmd, timeout)