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 a3b3aeb93b)
This commit is contained in:
Emilien Macchi 2020-08-19 15:06:28 -04:00
parent dc50728543
commit e2e5fd96b6
1 changed files with 25 additions and 0 deletions

View File

@ -45,6 +45,7 @@ DEFAULT_AUTHFILE = "{}/containers/auth.json".format(
DEFAULT_ENV_AUTHFILE = os.environ.get("REGISTRY_AUTH_FILE", DEFAULT_AUTHFILE) DEFAULT_ENV_AUTHFILE = os.environ.get("REGISTRY_AUTH_FILE", DEFAULT_AUTHFILE)
DEFAULT_CONFIG = "tripleo_containers.yaml" DEFAULT_CONFIG = "tripleo_containers.yaml"
DEFAULT_TCIB_CONFIG_BASE = "tcib" DEFAULT_TCIB_CONFIG_BASE = "tcib"
SUPPORTED_RHEL_MODULES = ['container-tools', 'mariadb', 'redis', 'virt']
class Build(command.Command): class Build(command.Command):
@ -207,6 +208,14 @@ class Build(command.Command):
"(default: %(default)s)" "(default: %(default)s)"
), ),
) )
parser.add_argument(
"--rhel-modules",
dest="rhel_modules",
metavar="<rhel-modules>",
default=None,
help=_("A comma separated list of RHEL modules to enable with "
"their version. Example: 'mariadb:10.3,virt:8.3'."),
)
return parser return parser
def imagename_to_regex(self, imagename): 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 '
'<module>:<version>')
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 # NOTE(cloudnull): Check if the reference config has a valid
# "from" option. If the reference "from" # "from" option. If the reference "from"
# option is valid, it will be used. # option is valid, it will be used.