From 974328f6835f57388934b31cd4f7c4ad0a20771b Mon Sep 17 00:00:00 2001 From: rakeshgm Date: Tue, 27 Oct 2020 18:55:07 +0530 Subject: [PATCH] redhat ds yaml location changed and redhat install tasks to accept lists fetch the dowstream yaml location from downstream teuth_config and redhat install tasks to accept lists too Signed-off-by: rakeshgm --- teuthology/task/install/redhat.py | 55 ++++++++++++++++-------------- teuthology/task/internal/redhat.py | 12 ++++--- 2 files changed, 38 insertions(+), 29 deletions(-) diff --git a/teuthology/task/install/redhat.py b/teuthology/task/install/redhat.py index 08568bda81..7bf1b5ebd0 100644 --- a/teuthology/task/install/redhat.py +++ b/teuthology/task/install/redhat.py @@ -6,6 +6,7 @@ import os from teuthology import packaging from teuthology.orchestra import run from teuthology.parallel import parallel +from teuthology.config import config as teuth_config log = logging.getLogger(__name__) @@ -40,28 +41,21 @@ def install(ctx, config): - ceph-osd - ceph-mds """ - yaml_path = None - # Look for rh specific packages in /rh/downstream.yaml - if 'suite_path' in ctx.config: - ds_yaml = os.path.join( - ctx.config['suite_path'], - 'rh', - 'downstream.yaml', - ) - if os.path.exists(ds_yaml): - yaml_path = ds_yaml - # default to user home dir if one exists - default_yaml = os.path.expanduser('~/downstream.yaml') - if os.path.exists(default_yaml): - yaml_path = default_yaml - log.info("using yaml path %s", yaml_path) - downstream_config = yaml.safe_load(open(yaml_path)) + # Look for rh specific packages + ds_yaml = os.path.join( + teuth_config.get('ds_yaml_dir'), + config.get('rhbuild') + ".yaml", + ) + if not os.path.exists(ds_yaml): + raise FileNotFoundError(f'Downstream rh version yaml file missing: {ds_yaml}') + log.info("using yaml path %s", ds_yaml) + downstream_config = yaml.safe_load(open(ds_yaml)) rh_versions = downstream_config.get('versions', dict()).get('supported', []) - external_config = dict(extra_system_packages=config.get('extra_system_packages', {}), - extra_packages=config.get('extra_packages', {}), + external_config = dict(extra_system_packages=config.get('extra_system_packages'), + extra_packages=config.get('extra_packages'), ) downstream_config.update(external_config) - version = config['rhbuild'] + version = config.get('rhbuild') if version in rh_versions: log.info("%s is a supported version", version) else: @@ -95,10 +89,16 @@ def install_pkgs(ctx, remote, version, downstream_config): :param downstream_config the dict object that has downstream pkg info """ rh_version_check = downstream_config.get('versions').get('rpm').get('mapped') - rh_rpm_pkgs = downstream_config.get('pkgs').get('rpm') + \ - downstream_config.get('extra_system_packages').get('rpm', []) + \ - downstream_config.get('extra_packages').get('rpm', []) + rh_rpm_pkgs = downstream_config.get('pkgs').get('rpm') + extras = [downstream_config.get('extra_system_packages'), + downstream_config.get('extra_packages')] + for extra in extras: + if isinstance(extra, dict): + rh_rpm_pkgs += extra.get('rpm', []) + elif isinstance(extra, list): + rh_rpm_pkgs += extra pkgs = str.join(' ', rh_rpm_pkgs) + log.info("Remove any epel packages installed on node %s", remote.shortname) # below packages can come from epel and still work, ensure we use cdn pkgs remote.run( @@ -172,9 +172,14 @@ def install_deb_pkgs( : param downstream_config the dict object that has downstream pkg info """ rh_version_check = downstream_config.get('versions').get('deb').get('mapped') - rh_deb_pkgs = downstream_config.get('pkgs').get('deb') + \ - downstream_config.get('extra_system_packages').get('deb', []) + \ - downstream_config.get('extra_packages').get('deb', []) + rh_deb_pkgs = downstream_config.get('pkgs').get('deb') + extras = [downstream_config.get('extra_system_packages'), + downstream_config.get('extra_packages')] + for extra in extras: + if isinstance(extra, dict): + rh_deb_pkgs += extra.get('deb', []) + elif isinstance(extra, list): + rh_deb_pkgs += extra pkgs = str.join(' ', rh_deb_pkgs) log.info("Installing redhat ceph packages") remote.run(args=['sudo', 'apt-get', '-y', 'install', diff --git a/teuthology/task/internal/redhat.py b/teuthology/task/internal/redhat.py index c43c9e6c6c..381b409898 100644 --- a/teuthology/task/internal/redhat.py +++ b/teuthology/task/internal/redhat.py @@ -26,6 +26,11 @@ def setup_stage_cdn(ctx, config): raise ConfigError("suite_path missing") teuthconfig.suite_path = suite_path + rhbuild = ctx.config.get('redhat').get('rhbuild') + if not rhbuild: + raise ConfigError('Provide rhbuild attribute') + teuthconfig.rhbuild = str(rhbuild) + with parallel() as p: for remote in ctx.cluster.remotes.keys(): if remote.os.name == 'rhel': @@ -105,11 +110,10 @@ def setup_additional_repo(ctx, config): def _enable_rhel_repos(remote): - # Look for rh specific repos in /rh/downstream.yaml + # Look for rh specific repos ds_yaml = os.path.join( - teuthconfig.suite_path, - 'rh', - 'downstream.yaml', + teuthconfig.get('ds_yaml_dir'), + teuthconfig.rhbuild + ".yaml" ) rhel_repos = yaml.safe_load(open(ds_yaml)) -- 2.39.5