From e2e5fd96b66e5ae4ae5589a5b18be55eaed0c6bb Mon Sep 17 00:00:00 2001 From: Emilien Macchi Date: Wed, 19 Aug 2020 15:06:28 -0400 Subject: [PATCH] TCIB: add --rhel-modules argument --rhel-modules is a new argument that will let us override the hardcoded RHEL module versions that are provided in the base image. For example, if we want to build the images against a specific module version, we'll now be able to do the following: $ openstack tripleo container image build --rhel-modules \ redis:5,virt:8.3 Note: for now we're opinionated about the RHEL modules that we support and the --rhel-modules won't allow to install any modules, but only the ones that we support: ['container-tools', 'mariadb', 'redis', 'virt']. The reason is that in theory all necessary modules should be provided in the base image layout in tripleo-common, and the use case here is being able to change their version from the CLI, specially for our release challenges with future OSP zstreams. Change-Id: Icaeabb2e7cb7adbbd7d2ef563dd613f2aacf8fe3 (cherry picked from commit a3b3aeb93b16bea51a53083e0b53faf5c15ee2bb) --- tripleoclient/v2/tripleo_container_image.py | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tripleoclient/v2/tripleo_container_image.py b/tripleoclient/v2/tripleo_container_image.py index 4209c6279..a39e3ab8c 100644 --- a/tripleoclient/v2/tripleo_container_image.py +++ b/tripleoclient/v2/tripleo_container_image.py @@ -45,6 +45,7 @@ DEFAULT_AUTHFILE = "{}/containers/auth.json".format( DEFAULT_ENV_AUTHFILE = os.environ.get("REGISTRY_AUTH_FILE", DEFAULT_AUTHFILE) DEFAULT_CONFIG = "tripleo_containers.yaml" DEFAULT_TCIB_CONFIG_BASE = "tcib" +SUPPORTED_RHEL_MODULES = ['container-tools', 'mariadb', 'redis', 'virt'] class Build(command.Command): @@ -207,6 +208,14 @@ class Build(command.Command): "(default: %(default)s)" ), ) + parser.add_argument( + "--rhel-modules", + dest="rhel_modules", + metavar="", + default=None, + help=_("A comma separated list of RHEL modules to enable with " + "their version. Example: 'mariadb:10.3,virt:8.3'."), + ) return parser def imagename_to_regex(self, imagename): @@ -460,6 +469,22 @@ class Build(command.Command): } ) + if parsed_args.rhel_modules: + rhel_modules = {} + for module in parsed_args.rhel_modules.split(','): + try: + name, version = module.split(':', 1) + except Exception: + raise ValueError('Wrong format for --rhel-modules, ' + 'must be a comma separated list of ' + ':') + if name not in SUPPORTED_RHEL_MODULES: + raise ValueError('{} is not part of supported modules' + ' {}'.format(name, + SUPPORTED_RHEL_MODULES)) + rhel_modules.update({name: version}) + image_config['tcib_rhel_modules'] = rhel_modules + # NOTE(cloudnull): Check if the reference config has a valid # "from" option. If the reference "from" # option is valid, it will be used.