]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
suite/run: include 'user' and 'timestamp' in job conf 1531/head
authorKyr Shatskyy <kyrylo.shatskyy@suse.com>
Tue, 12 May 2020 15:02:26 +0000 (17:02 +0200)
committerKyr Shatskyy <kyrylo.shatskyy@suse.com>
Mon, 6 Jul 2020 16:45:25 +0000 (18:45 +0200)
This is useful to avoid unnecessary parsing of job name in order
to get run user and timestamp.

Signed-off-by: Kyr Shatskyy <kyrylo.shatskyy@suse.com>
teuthology/suite/run.py

index 63169910bf38085d2dcebc39d3e781f05e4abc79..73f7b134489bfb859187c4cc2dad88425b08489d 100644 (file)
@@ -32,6 +32,7 @@ class Run(object):
     __slots__ = (
         'args', 'name', 'base_config', 'suite_repo_path', 'base_yaml_paths',
         'base_args', 'package_versions', 'kernel_dict', 'config_input',
+        'timestamp', 'user',
     )
 
     def __init__(self, args):
@@ -39,6 +40,11 @@ class Run(object):
         args must be a config.YamlConfig object
         """
         self.args = args
+        # We assume timestamp is a datetime.datetime object
+        self.timestamp = self.args.timestamp or \
+            datetime.now().strftime('%Y-%m-%d_%H:%M:%S')
+        self.user = self.args.user or pwd.getpwuid(os.getuid()).pw_name
+
         self.name = self.make_run_name()
 
         if self.args.ceph_repo:
@@ -60,16 +66,15 @@ class Run(object):
         Generate a run name. A run name looks like:
             teuthology-2014-06-23_19:00:37-rados-dumpling-testing-basic-plana
         """
-        user = self.args.user or pwd.getpwuid(os.getuid()).pw_name
-        # We assume timestamp is a datetime.datetime object
-        timestamp = self.args.timestamp or \
-            datetime.now().strftime('%Y-%m-%d_%H:%M:%S')
-
         worker = util.get_worker(self.args.machine_type)
         return '-'.join(
             [
-                user, str(timestamp), self.args.suite, self.args.ceph_branch,
-                self.args.kernel_branch or '-', self.args.kernel_flavor, worker
+                self.user,
+                str(self.timestamp),
+                self.args.suite,
+                self.args.ceph_branch,
+                self.args.kernel_branch or '-',
+                self.args.kernel_flavor, worker
             ]
         ).replace('/', ':')
 
@@ -309,6 +314,8 @@ class Run(object):
         conf_dict.update(self.kernel_dict)
         job_config = JobConfig.from_dict(conf_dict)
         job_config.name = self.name
+        job_config.user = self.user
+        job_config.timestamp = self.timestamp
         job_config.priority = self.args.priority
         if self.args.email:
             job_config.email = self.args.email