From ae5fcc0dd1d19c750cba8d9bf16545f5a7802287 Mon Sep 17 00:00:00 2001 From: Tim Rozet Date: Mon, 13 Aug 2018 14:51:09 -0400 Subject: Allow common patches file This patch adds allowing for common patches that should be applied to every scenario to be included. It by default pulls in a file in the deploy directory 'common-patches.yaml', but can optionally be overridden. This patch also includes a patch upstream to fix OSCLI not working anymore due to breakage with the Cinder version in the overcloudrc. Change-Id: I97b9efb937deff07e085b9ef75b9799fb65bfc57 Signed-off-by: Tim Rozet --- apex/deployment/__init__.py | 0 apex/deployment/tripleo.py | 59 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 apex/deployment/__init__.py create mode 100644 apex/deployment/tripleo.py (limited to 'apex/deployment') diff --git a/apex/deployment/__init__.py b/apex/deployment/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/apex/deployment/tripleo.py b/apex/deployment/tripleo.py new file mode 100644 index 00000000..0f85bbae --- /dev/null +++ b/apex/deployment/tripleo.py @@ -0,0 +1,59 @@ +############################################################################## +# Copyright (c) 2018 Tim Rozet (trozet@redhat.com) and others. +# +# 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 +############################################################################## + +# TODO(trozet): this will serve as the deployment class as we migrate logic out +# of deploy.py +import logging +import os +import pprint + +from apex.common.exceptions import ApexDeployException +from apex.common import utils + + +class ApexDeployment: + def __init__(self, deploy_settings, patch_file, ds_file): + self.ds = deploy_settings + # TODO(trozet): remove ds_file from args and have this class inherit + # super deployment class init which does all the settings + self.ds_file = ds_file + self.ds_globals = self.ds['global_params'] + self.p_file = patch_file + + def determine_patches(self): + patches = self.ds_globals['patches'] + if not os.path.isfile(self.p_file): + new_file = os.path.join(os.path.dirname(self.ds_file), + 'common-patches.yaml') + if os.path.isfile(new_file): + logging.warning('Patch file {} not found, falling back to ' + '{}'.format(self.p_file, new_file)) + self.p_file = new_file + else: + logging.error('Unable to find common patch file: ' + '{}'.format(self.p_file)) + raise ApexDeployException( + 'Specified common patch file not found: {}'.format( + self.p_file)) + logging.info('Loading patches from common patch file {}'.format( + self.p_file)) + common_patches = utils.parse_yaml(self.p_file) + logging.debug('Content from common patch file is: {}'.format( + pprint.pformat(common_patches))) + if 'patches' not in common_patches.keys(): + logging.error('Error parsing common patches file, wrong format. ' + 'Missing "patches" dictionary') + raise ApexDeployException('Invalid format of common patch file') + else: + common_patches = common_patches['patches'] + for ptype in ('undercloud', 'overcloud'): + if ptype in common_patches: + patches[ptype] = utils.unique(patches[ptype] + + common_patches[ptype]) + return patches -- cgit 1.2.3-korg