Updates Calipso deploy settings
[apex.git] / apex / builders / undercloud_builder.py
1 ##############################################################################
2 # Copyright (c) 2017 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 # Used to modify undercloud qcow2 image
11 import logging
12 import os
13
14 from apex.common import constants as con
15 from apex.common import utils
16 from apex.virtual import utils as virt_utils
17
18
19 def add_upstream_packages(image):
20     """
21     Adds required base upstream packages to Undercloud for deployment
22     :param image:
23     :return: None
24     """
25     virt_ops = list()
26     pkgs = [
27         'epel-release',
28         'openstack-utils',
29         'ceph-common',
30         'python2-networking-sfc',
31         'openstack-ironic-inspector',
32         'subunit-filters',
33         'docker-distribution',
34         'openstack-tripleo-validations',
35         'libguestfs-tools',
36         'ceph-ansible',
37         'python-tripleoclient'
38     ]
39
40     for pkg in pkgs:
41         virt_ops.append({con.VIRT_INSTALL: pkg})
42     virt_utils.virt_customize(virt_ops, image)
43
44
45 def inject_calipso_installer(tmp_dir, image):
46     """
47     Downloads calipso installer script from artifacts.opnfv.org
48     and puts it under /root/ for further installation process.
49     :return:
50     """
51     calipso_file = os.path.basename(con.CALIPSO_INSTALLER_URL)
52     calipso_url = con.CALIPSO_INSTALLER_URL.replace(calipso_file, '')
53     utils.fetch_upstream_and_unpack(tmp_dir, calipso_url, [calipso_file])
54
55     virt_ops = [
56         {con.VIRT_UPLOAD: "{}/{}:/root/".format(tmp_dir, calipso_file)}]
57     virt_utils.virt_customize(virt_ops, image)
58     logging.info("Calipso injected into {}".format(image))
59
60 # TODO(trozet): add unit testing for calipso injector
61 # TODO(trozet): add rest of build for undercloud here as well