]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
qa/tasks/ceph: use Cluster.sh() and Remote.sh() when appropriate
authorKefu Chai <kchai@redhat.com>
Tue, 10 Nov 2020 07:03:21 +0000 (15:03 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 14 Nov 2020 07:22:10 +0000 (15:22 +0800)
for better readability

Signed-off-by: Kefu Chai <kchai@redhat.com>
qa/tasks/ceph.py

index 0f547576f4c3552fa06b25f1cf070530eaf7dcff..50173b4bb8e0fde75b16a5113854798bc05f738e 100644 (file)
@@ -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')