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', conf['ssh_opts'] = ['-oConnectTimeout=2', '-oStrictHostKeyChecking=no',
'-oUserKnownHostsFile=/dev/null', '-oLogLevel=error', '-oUserKnownHostsFile=/dev/null', '-oLogLevel=error',
'-oBatchMode=yes', '-oUser=root'] '-oBatchMode=yes', '-oUser=root']
conf['rsync_opts'] = ['-avzrL', '--progress', '--partial',
'--delete-before']
conf['env_vars'] = ['OPENRC=/root/openrc', 'LC_ALL="C"', 'LANG="C"'] conf['env_vars'] = ['OPENRC=/root/openrc', 'LC_ALL="C"', 'LANG="C"']
conf['timeout'] = 30 conf['timeout'] = 30
conf['prefix'] = 'nice -n 19 ionice -c 3' 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, o, e, c = tools.get_files_rsync(ip=self.ip,
data=data, data=data,
ssh_opts=self.ssh_opts, ssh_opts=self.ssh_opts,
rsync_opts=self.rsync_opts,
dpath=ddir, dpath=ddir,
timeout=self.timeout) timeout=self.timeout)
self.check_code(c, 'get_files', 'tools.get_files_rsync', e) 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) 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: if type(ssh_opts) is list:
ssh_opts = ' '.join(ssh_opts) 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.'): if (ip in ['localhost', '127.0.0.1']) or ip.startswith('127.'):
logger.info("skip ssh rsync") logger.info("skip ssh rsync")
cmd = ("timeout '%s' rsync -avzr --include-from=- / '%s' --exclude='*'" cmd = ("timeout '%s' rsync %s --include-from=- / '%s' --exclude='*'" %
" --progress --partial --delete-before" % (timeout, rsync_opts, dpath))
(timeout, dpath))
else: else:
cmd = ("timeout '%s' rsync -avzr -e 'ssh %s" cmd = ("timeout '%s' rsync %s -e 'ssh %s -oCompression=no' "
" -oCompression=no' --include-from=- '%s':/ '%s' --exclude='*'" "--include-from=- '%s':/ '%s' --exclude='*'" %
" --progress --partial --delete-before" (timeout, rsync_opts, ssh_opts, ip, dpath))
) % (timeout, ssh_opts, ip, dpath)
logger.debug("command:%s\ndata:\n%s" % (cmd, data)) logger.debug("command:%s\ndata:\n%s" % (cmd, data))
if data == '': if data == '':
return cmd, '', 127 return cmd, '', 127