Add base_package_type

Currently in all the Dockerfile.j2 files, we are doing base distro if
conditions for package names when installing via a binary.  Rather than
duplicating these base_distro in [<distros>], let's provide a single
value for determining the binary installation method. This change adds a
base_package_type which we can use to lookup if 'rpm' or if 'deb' rather
than relying on specific distro names.

Change-Id: I8a0c6c8fbc32a8cfa6932fddf28a449fceda3d49
This commit is contained in:
Alex Schultz 2019-01-15 16:33:24 -07:00
parent 3410a6165a
commit fca732b81e
4 changed files with 38 additions and 0 deletions

View File

@ -270,6 +270,10 @@ _BASE_OPTS = [
help=('Enable this to force python3 packaging names. By ' help=('Enable this to force python3 packaging names. By '
'default this will try and determine the value of this ' 'default this will try and determine the value of this '
'based on the base_distro and base_distro_tag.')), 'based on the base_distro and base_distro_tag.')),
cfg.StrOpt('base_package_type', default=None,
help=('Set the package type of the distro. If not set then '
'the packaging type is set to "rpm" if a RHEL based '
'distro and "deb" if a Debian based distro.')),
cfg.ListOpt('rpm_setup_config', default=[DELOREAN, DELOREAN_DEPS], cfg.ListOpt('rpm_setup_config', default=[DELOREAN, DELOREAN_DEPS],
help=('Comma separated list of .rpm or .repo file(s) ' help=('Comma separated list of .rpm or .repo file(s) '
'or URL(s) to install before building containers')), 'or URL(s) to install before building containers')),

View File

@ -697,6 +697,14 @@ class KollaWorker(object):
else: else:
self.distro_python3 = False self.distro_python3 = False
# Determine base packaging type for use in Dockerfiles.
if self.conf.base_package_type:
self.base_package_type = self.conf.base_package_type
elif self.base in rh_base:
self.base_package_type = 'rpm'
elif self.base in deb_base:
self.base_package_type = 'deb'
if not ((self.base in rh_base and self.install_type in rh_type) or if not ((self.base in rh_base and self.install_type in rh_type) or
(self.base in deb_base and self.install_type in deb_type)): (self.base in deb_base and self.install_type in deb_type)):
raise exception.KollaMismatchBaseTypeException( raise exception.KollaMismatchBaseTypeException(
@ -886,6 +894,7 @@ class KollaWorker(object):
'base_image': self.conf.base_image, 'base_image': self.conf.base_image,
'base_distro_tag': self.base_tag, 'base_distro_tag': self.base_tag,
'base_arch': self.base_arch, 'base_arch': self.base_arch,
'base_package_type': self.base_package_type,
'supported_distro_release': supported_distro_release, 'supported_distro_release': supported_distro_release,
'install_metatype': self.install_metatype, 'install_metatype': self.install_metatype,
'image_prefix': self.image_prefix, 'image_prefix': self.image_prefix,

View File

@ -401,6 +401,24 @@ class KollaWorkerTest(base.TestCase):
kolla = build.KollaWorker(self.conf) kolla = build.KollaWorker(self.conf)
self.assertFalse(kolla.distro_python3) self.assertFalse(kolla.distro_python3)
def test_base_package_type(self):
"""check base_package_type conf value is taken"""
self.conf.set_override('base_package_type', 'pip')
kolla = build.KollaWorker(self.conf)
self.assertEqual('pip', kolla.base_package_type)
def test_base_package_type_rhel(self):
"""check base_package_type rpm for rhel"""
self.conf.set_override('base', 'rhel')
kolla = build.KollaWorker(self.conf)
self.assertEqual('rpm', kolla.base_package_type)
def test_base_package_type_debian(self):
"""check base_package_type deb for debian"""
self.conf.set_override('base', 'debian')
kolla = build.KollaWorker(self.conf)
self.assertEqual('deb', kolla.base_package_type)
def test_pre_defined_exist_profile(self): def test_pre_defined_exist_profile(self):
# default profile include the fake image: image-base # default profile include the fake image: image-base
self.conf.set_override('profile', ['default']) self.conf.set_override('profile', ['default'])

View File

@ -0,0 +1,7 @@
---
features:
- |
Add `base_package_type` which can be used in Dockerfile.j2 files instead
of checking based on distro names. This will default to "rpm" for RHEL
based distros and "deb" for Debian based systems. This can also be overriden
to any string value via a configuration file.