diff options
Diffstat (limited to 'utils/agljobtemplate.py')
-rw-r--r-- | utils/agljobtemplate.py | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/utils/agljobtemplate.py b/utils/agljobtemplate.py index 528a3b9..b4d44af 100644 --- a/utils/agljobtemplate.py +++ b/utils/agljobtemplate.py @@ -4,11 +4,21 @@ import os import jinja2 import ConfigParser +import urlparse def get_extension(path): return path.split('.')[-1] +def parse_url_file(template_path, url_file, url_type): + url_file_path = template_path + '/URLs/' + url_file + try: + with open(url_file_path): + cfg = ConfigParser.ConfigParser() + cfg.read(url_file_path) + return cfg.get(url_type, 'urlbase'), cfg.get('infra', 'style') + except IOError: + raise IOError, "Unable to read from file {}".format(url_file_path) def parse_callback_file(template_path, callback_file, job): callback_file_path = template_path + '/callback/' + callback_file + '.cfg' @@ -59,7 +69,8 @@ class Agljobtemplate(object): def rfs_types(self): return self.RFS_TYPE - def render_job(self, url, machine, job_name="AGL-short-smoke", priority="medium", tests=[], rfs_type=None, + def render_job(self, url, machine, url_branch=None, url_version=None, + job_name="AGL-short-smoke", priority="medium", tests=[], rfs_type=None, kci_callback=None, rfs_image=None, kernel_image=None, dtb_image=None, modules_image=None, build_version=None): test_templates = [] @@ -78,9 +89,32 @@ class Agljobtemplate(object): job['name'] = job_name job['yocto_machine'] = machine job['priority'] = priority + + if url[:4] != 'http': + # If not a full url, read from config file + url_base, infra = parse_url_file(self._template_path, 'default.cfg', url) + if infra == 'AGL': + url_fragment = '' + if (url != 'default'): + url_fragment += url_branch + '/' + url_version + '/' + + if (machine == 'm3ulcb') or (machine == 'porter'): + url_fragment += machine + '-nogfx' + else: + url_fragment += machine + + if (url != 'ci'): + url_fragment += '/deploy/images/' + machine + + url = urlparse.urljoin(url_base, url_fragment) + job['urlbase'] = url + job['test_templates'] = test_templates + if (not build_version) and (url_branch) and (url_version): + build_version = 'AGL-' + url + '-' + url_branch + '-' + url_version + if build_version is not None: job['kernel_version'] = build_version |