add: login parameter for ssh

Change-Id: I4f770d8d48e34fa98bf60d43eba8086db2ece9f9
Fix: issue 61
This commit is contained in:
Aleksandr Dobdin 2016-09-29 15:18:49 +00:00
parent 0ef46e49a1
commit d2786d8aae
3 changed files with 13 additions and 7 deletions

View File

@ -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'

View File

@ -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)

View File

@ -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)