diff options
Diffstat (limited to 'apex/undercloud/undercloud.py')
-rw-r--r-- | apex/undercloud/undercloud.py | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/apex/undercloud/undercloud.py b/apex/undercloud/undercloud.py index 013570d3..915c85f3 100644 --- a/apex/undercloud/undercloud.py +++ b/apex/undercloud/undercloud.py @@ -31,8 +31,10 @@ class Undercloud: """ def __init__(self, image_path, template_path, root_pw=None, external_network=False, - image_name='undercloud.qcow2'): + image_name='undercloud.qcow2', + os_version=constants.DEFAULT_OS_VERSION): self.ip = None + self.os_version = os_version self.root_pw = root_pw self.external_net = external_network self.volume = os.path.join(constants.LIBVIRT_VOLUME_PATH, @@ -61,17 +63,19 @@ class Undercloud: if self.external_net: networks.append('external') console = 'ttyAMA0' if platform.machine() == 'aarch64' else 'ttyS0' + root = 'vda' if platform.machine() == 'aarch64' else 'sda' self.vm = vm_lib.create_vm(name='undercloud', image=self.volume, baremetal_interfaces=networks, direct_boot='overcloud-full', kernel_args=['console={}'.format(console), - 'root=/dev/sda'], + 'root=/dev/{}'.format(root)], default_network=True, template_dir=self.template_path) self.setup_volumes() self.inject_auth() + self._update_delorean_repo() def _set_ip(self): ip_out = self.vm.interfaceAddresses( @@ -110,10 +114,12 @@ class Undercloud: "Unable to find IP for undercloud. Check if VM booted " "correctly") - def configure(self, net_settings, playbook, apex_temp_dir): + def configure(self, net_settings, deploy_settings, + playbook, apex_temp_dir): """ Configures undercloud VM - :param net_setings: Network settings for deployment + :param net_settings: Network settings for deployment + :param deploy_settings: Deployment settings for deployment :param playbook: playbook to use to configure undercloud :param apex_temp_dir: temporary apex directory to hold configs/logs :return: None @@ -121,7 +127,8 @@ class Undercloud: logging.info("Configuring Undercloud...") # run ansible - ansible_vars = Undercloud.generate_config(net_settings) + ansible_vars = Undercloud.generate_config(net_settings, + deploy_settings) ansible_vars['apex_temp_dir'] = apex_temp_dir try: utils.run_ansible(ansible_vars, playbook, host=self.ip, @@ -179,21 +186,28 @@ class Undercloud: virt_utils.virt_customize(virt_ops, self.volume) @staticmethod - def generate_config(ns): + def generate_config(ns, ds): """ Generates a dictionary of settings for configuring undercloud :param ns: network settings to derive undercloud settings + :param ds: deploy settings to derive undercloud settings :return: dictionary of settings """ ns_admin = ns['networks']['admin'] intro_range = ns['apex']['networks']['admin']['introspection_range'] config = dict() + # Check if this is an ARM deployment + config['aarch64'] = platform.machine() == 'aarch64' + # Configuration for undercloud.conf config['undercloud_config'] = [ "enable_ui false", "undercloud_update_packages false", "undercloud_debug false", "inspection_extras false", + "ipxe_enabled {}".format( + str(ds['global_params'].get('ipxe', True) and + not config['aarch64'])), "undercloud_hostname undercloud.{}".format(ns['dns-domain']), "local_ip {}/{}".format(str(ns_admin['installer_vm']['ip']), str(ns_admin['cidr']).split('/')[1]), @@ -226,7 +240,22 @@ class Undercloud: "enabled": ns_external['enabled'] } - # Check if this is an ARM deployment - config['aarch64'] = platform.machine() == 'aarch64' + config['http_proxy'] = ns.get('http_proxy', '') + config['https_proxy'] = ns.get('https_proxy', '') return config + + def _update_delorean_repo(self): + if utils.internet_connectivity(): + logging.info('Updating delorean repo on Undercloud') + delorean_repo = ( + "https://trunk.rdoproject.org/centos7-{}" + "/current-tripleo/delorean.repo".format(self.os_version)) + cmd = ("curl -L -f -o " + "/etc/yum.repos.d/deloran.repo {}".format(delorean_repo)) + try: + virt_utils.virt_customize({constants.VIRT_RUN_CMD: cmd}, + self.volume) + except Exception: + logging.warning("Failed to download and update delorean repo " + "for Undercloud") |