]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
suite/run.py: refactor to reuse config substitution code
authorDan Mick <dan.mick@redhat.com>
Mon, 27 Jun 2016 21:45:32 +0000 (14:45 -0700)
committerDan Mick <dan.mick@redhat.com>
Mon, 27 Jun 2016 22:51:29 +0000 (15:51 -0700)
In --newest mode we must recreate the base config, because
the ceph sha1 has been substituted several times already.
Factor the substitution code out of create_initial_config so
that it can be called from the backtracking code (which requires
storing kernel_dict and config_input on the instance).

Signed-off-by: Dan Mick <dan.mick@redhat.com>
teuthology/suite/run.py

index ceb82f05c66740909ac4eb87743718cc5e443439..bce780f8233de14dfc90be1d4e6be264f9584933 100644 (file)
@@ -25,7 +25,7 @@ class Run(object):
     WAIT_PAUSE = 5 * 60
     __slots__ = (
         'args', 'name', 'base_config', 'suite_repo_path', 'base_yaml_paths',
-        'base_args', 'package_versions',
+        'base_args', 'package_versions', 'kernel_dict', 'config_input',
     )
 
     def __init__(self, args):
@@ -76,7 +76,7 @@ class Run(object):
 
         :returns: A JobConfig object
         """
-        kernel_dict = self.choose_kernel()
+        self.kernel_dict = self.choose_kernel()
         ceph_hash = self.choose_ceph_hash()
         # We don't store ceph_version because we don't use it yet outside of
         # logging.
@@ -85,7 +85,7 @@ class Run(object):
         suite_branch = self.choose_suite_branch()
         suite_hash = self.choose_suite_hash(suite_branch)
 
-        config_input = dict(
+        self.config_input = dict(
             suite=self.args.suite,
             suite_branch=suite_branch,
             suite_hash=suite_hash,
@@ -97,10 +97,7 @@ class Run(object):
             archive_upload=config.archive_upload,
             archive_upload_key=config.archive_upload_key,
         )
-        conf_dict = substitute_placeholders(dict_templ, config_input)
-        conf_dict.update(kernel_dict)
-        job_config = JobConfig.from_dict(conf_dict)
-        return job_config
+        return self.build_base_config()
 
     def choose_kernel(self):
         # Put together a stanza specifying the kernel hash
@@ -211,6 +208,12 @@ class Run(object):
             util.schedule_fail(message=str(exc), name=self.name)
         log.info("ceph-qa-suite branch: %s %s", suite_branch, suite_hash)
 
+    def build_base_config(self):
+        conf_dict = substitute_placeholders(dict_templ, self.config_input)
+        conf_dict.update(self.kernel_dict)
+        job_config = JobConfig.from_dict(conf_dict)
+        return job_config
+
     def build_base_args(self):
         base_args = [
             '--name', self.name,
@@ -260,7 +263,6 @@ class Run(object):
             if results_url:
                 log.info("Test results viewable at %s", results_url)
 
-
     def collect_jobs(self, arch, configs, newest=False):
         jobs_to_schedule = []
         jobs_missing_packages = []