]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/tasks/salt_manager: allow gatherlogs for files in subdir
authorKyr Shatskyy <kyrylo.shatskyy@suse.com>
Tue, 13 Jul 2021 14:05:51 +0000 (16:05 +0200)
committerStefen Allen <sallen@suse.com>
Thu, 9 Dec 2021 19:29:47 +0000 (12:29 -0700)
Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@suse.com>
qa/tasks/salt_manager.py

index 9da0f85a77c4bf83faf39c7e41af506137f3321b..44db48f2b6e6532d44ddbd9e95638a4e56ce1536 100644 (file)
@@ -17,6 +17,7 @@ Linter:
     flake8 --max-line-length=100
 '''
 import logging
+import os
 import re
 
 from teuthology.contextutil import safe_while
@@ -168,22 +169,25 @@ class SaltManager(object):
         systemctl_remote(self.ctx.cluster, "enable", "salt-minion")
 
     def gather_logfile(self, logfile):
+        archivedir = '/home/ubuntu/cephtest/archive'
         for _remote in self.ctx.cluster.remotes.keys():
+            if logfile.startswith('/'):
+                filepath = logfile
+            else:
+                filepath = f'/var/log/{logfile}'
+            filename = os.path.basename(logfile)
             try:
                 _remote.run(args=[
-                    'sudo', 'test', '-f', '/var/log/{}'.format(logfile),
+                    'sudo', 'test', '-f', filepath,
                     ])
             except CommandFailedError:
                 continue
-            log.info((
-                "gathering logfile /var/log/{} from remote {}"
-                ).format(logfile, _remote.hostname))
+            log.info(
+                f"gathering logfile {filepath} from remote {_remote.hostname}")
             _remote.run(args=[
-                'sudo', 'cp', '-a', '/var/log/{}'.format(logfile),
-                '/home/ubuntu/cephtest/archive/',
+                'sudo', 'cp', '-a', filepath, f'{archivedir}/',
                 run.Raw(';'),
-                'sudo', 'chown', 'ubuntu',
-                '/home/ubuntu/cephtest/archive/{}'.format(logfile)
+                'sudo', 'chown', 'ubuntu', f'{archivedir}/{filename}'
                 ])
 
     def gather_logs(self, logdir, archive=None):