Disable blocking on buildable queue (Functest)
[releng.git] / jjb / apex / apex-jjb-renderer.py
1 ##############################################################################
2 # Copyright (c) 2016 Tim Rozet (trozet@redhat.com) and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10 import pprint
11 import yaml
12 from jinja2 import Environment
13 from jinja2 import FileSystemLoader
14
15
16 def render_jjb():
17     """Render JJB output from scenarios.yaml.hidden file and jinja
18     template"""
19
20     gspathname = dict()
21     branch = dict()
22     build_slave = dict()
23     env = Environment(loader=FileSystemLoader('./'), autoescape=True,
24                       keep_trailing_newline=True)
25
26     with open('scenarios.yaml.hidden') as _:
27         scenarios = yaml.safe_load(_)
28
29     template = env.get_template('apex.yaml.j2')
30
31     print("Scenarios are: ")
32     pprint.pprint(scenarios)
33
34     for stream in scenarios:
35         if stream == 'master':
36             gspathname['master'] = ''
37             branch[stream] = stream
38         else:
39             gspathname[stream] = '/' + stream
40             branch[stream] = 'stable/' + stream
41         build_slave[stream] = 'apex-baremetal-{}'.format(stream)
42
43     output = template.render(scenarios=scenarios, gspathname=gspathname,
44                              branch=branch, build_slave=build_slave)
45
46     with open('./apex.yaml', 'w') as fh:
47         fh.write(output)
48
49
50 if __name__ == "__main__":
51     render_jjb()