Add: make rsync options configurable

Change-Id: Iedbd1b9f7d1925d4788abd6b2ea48e89aaef737f
Related-Bug: #1628201
This commit is contained in:
Dmitry Sutyagin 2016-11-14 16:50:39 -08:00
parent 4c1a1f6ebd
commit ebd8719035
3 changed files with 11 additions and 8 deletions

View File

@ -30,6 +30,8 @@ def init_default_conf():
conf['ssh_opts'] = ['-oConnectTimeout=2', '-oStrictHostKeyChecking=no',
'-oUserKnownHostsFile=/dev/null', '-oLogLevel=error',
'-oBatchMode=yes', '-oUser=root']
conf['rsync_opts'] = ['-avzrL', '--progress', '--partial',
'--delete-before']
conf['env_vars'] = ['OPENRC=/root/openrc', 'LC_ALL="C"', 'LANG="C"']
conf['timeout'] = 30
conf['prefix'] = 'nice -n 19 ionice -c 3'

View File

@ -374,6 +374,7 @@ class Node(object):
o, e, c = tools.get_files_rsync(ip=self.ip,
data=data,
ssh_opts=self.ssh_opts,
rsync_opts=self.rsync_opts,
dpath=ddir,
timeout=self.timeout)
self.check_code(c, 'get_files', 'tools.get_files_rsync', e)

View File

@ -341,19 +341,19 @@ def ssh_node(ip, command='', ssh_opts=None, env_vars=None, timeout=15,
ok_codes=ok_codes, decode=decode)
def get_files_rsync(ip, data, ssh_opts, dpath, timeout=15):
def get_files_rsync(ip, data, ssh_opts, rsync_opts, dpath, timeout=15):
if type(ssh_opts) is list:
ssh_opts = ' '.join(ssh_opts)
if type(rsync_opts) is list:
rsync_opts = ' '.join(rsync_opts)
if (ip in ['localhost', '127.0.0.1']) or ip.startswith('127.'):
logger.info("skip ssh rsync")
cmd = ("timeout '%s' rsync -avzr --include-from=- / '%s' --exclude='*'"
" --progress --partial --delete-before" %
(timeout, dpath))
cmd = ("timeout '%s' rsync %s --include-from=- / '%s' --exclude='*'" %
(timeout, rsync_opts, dpath))
else:
cmd = ("timeout '%s' rsync -avzr -e 'ssh %s"
" -oCompression=no' --include-from=- '%s':/ '%s' --exclude='*'"
" --progress --partial --delete-before"
) % (timeout, ssh_opts, ip, dpath)
cmd = ("timeout '%s' rsync %s -e 'ssh %s -oCompression=no' "
"--include-from=- '%s':/ '%s' --exclude='*'" %
(timeout, rsync_opts, ssh_opts, ip, dpath))
logger.debug("command:%s\ndata:\n%s" % (cmd, data))
if data == '':
return cmd, '', 127