From: Kefu Chai Date: Tue, 10 Nov 2020 07:03:21 +0000 (+0800) Subject: qa/tasks/ceph: use Cluster.sh() and Remote.sh() when appropriate X-Git-Tag: v17.0.0~605^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=95366255584093a251f14a16746c826a46fde5b2;p=ceph-ci.git qa/tasks/ceph: use Cluster.sh() and Remote.sh() when appropriate for better readability Signed-off-by: Kefu Chai --- diff --git a/qa/tasks/ceph.py b/qa/tasks/ceph.py index 0f547576f4c..50173b4bb8e 100644 --- a/qa/tasks/ceph.py +++ b/qa/tasks/ceph.py @@ -230,24 +230,10 @@ def ceph_log(ctx, config): for remote in ctx.cluster.remotes.keys(): remote.write_file(remote_logrotate_conf, BytesIO(conf.encode())) - remote.run( - args=[ - 'sudo', - 'mv', - remote_logrotate_conf, - '/etc/logrotate.d/ceph-test.conf', - run.Raw('&&'), - 'sudo', - 'chmod', - '0644', - '/etc/logrotate.d/ceph-test.conf', - run.Raw('&&'), - 'sudo', - 'chown', - 'root.root', - '/etc/logrotate.d/ceph-test.conf' - ] - ) + remote.sh( + f'sudo mv {remote_logrotate_conf} /etc/logrotate.d/ceph-test.conf && ' + 'sudo chmod 0644 /etc/logrotate.d/ceph-test.conf && ' + 'sudo chown root.root /etc/logrotate.d/ceph-test.conf') remote.chcon('/etc/logrotate.d/ceph-test.conf', 'system_u:object_r:etc_t:s0') @@ -264,35 +250,15 @@ def ceph_log(ctx, config): if ctx.config.get('log-rotate'): log.info('Shutting down logrotate') logrotater.end() - ctx.cluster.run( - args=['sudo', 'rm', '/etc/logrotate.d/ceph-test.conf' - ] - ) + ctx.cluster.sh('sudo rm /etc/logrotate.d/ceph-test.conf') if ctx.archive is not None and \ not (ctx.config.get('archive-on-error') and ctx.summary['success']): # and logs log.info('Compressing logs...') - run.wait( - ctx.cluster.run( - args=[ - 'sudo', - 'find', - '/var/log/ceph', - '-name', - '*.log', - '-print0', - run.Raw('|'), - 'sudo', - 'xargs', - '-0', - '--no-run-if-empty', - '--', - 'gzip', - '--', - ], - wait=False, - ), - ) + ctx.cluster.sh( + 'sudo find /var/log/ceph -name *.log -print0 | ' + 'sudo xargs -0 --no-run-if-empty -- gzip --', + wait=False) log.info('Archiving logs...') path = os.path.join(ctx.archive, 'remote')