aboutsummaryrefslogtreecommitdiffstats
path: root/build/f_isoroot/f_repobuild/opnfv_mirror_conf.py
blob: 1c7eb591ad660127d47fa94cbdfb1bed0eb8329c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
##############################################################################
# Copyright (c) 2015 Ericsson AB and others.
# mskalski@mirantis.com
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
import os
import yaml

current_snapshot =  os.environ["LATEST_TARGET_UBUNTU"]
mos_version = os.environ['MOS_VERSION']
openstack_version = os.environ['OPENSTACK_VERSION']
mos_ubuntu = os.environ['MIRROR_MOS_UBUNTU']
mos_ubuntu_root = os.environ['MIRROR_MOS_UBUNTU_ROOT']
mirror_ubuntu = os.environ['MIRROR_UBUNTU_URL']
if os.environ.get('BUILD_FUEL_PLUGINS'):
  plugins = os.environ['BUILD_FUEL_PLUGINS']
else:
  plugins = os.environ['PLUGINS']


configuration_file = open('fuel-mirror/contrib/fuel_mirror/etc/config.yaml').read()
conf = yaml.load(configuration_file)
conf['pattern_dir'] = '.'
conf['openstack_version'] = openstack_version
conf['mos_version'] = mos_version

with open('opnfv-config.yaml', 'w') as outfile:
  outfile.write( yaml.dump(conf, default_flow_style=False) )

pattern_file = open('fuel-mirror/contrib/fuel_mirror/data/ubuntu.yaml').read()
pattern = yaml.load(pattern_file)
pattern['mos_baseurl'] = "http://{}{}".format(mos_ubuntu, mos_ubuntu_root)
pattern['ubuntu_baseurl'] = mirror_ubuntu
for group in pattern['groups']['mos']:
  group['uri'] = pattern['mos_baseurl']
for group in pattern['groups']['ubuntu']:
  group['uri'] = pattern['ubuntu_baseurl']

for plugin in plugins.split():
  path = "../{}/packages.yaml".format(plugin)
  if os.path.isfile(path):
    f = open(path).read()
    plugin_yaml = yaml.load(f)
    plugin_set = set(plugin_yaml['packages'])
    main_set = set(pattern['packages'])
    new_packages = plugin_set - main_set
    print "Plugin {} require new packages: {}".format(plugin, ', '.join(new_packages))
    pattern['packages'] = pattern['packages'] + list(new_packages)

pattern['requirements']['ubuntu'] = pattern['packages']

with open('ubuntu.yaml', 'w') as outfile:
  outfile.write( yaml.safe_dump(pattern, default_flow_style=False) )