aboutsummaryrefslogtreecommitdiff
path: root/kolla
diff options
context:
space:
mode:
authorAlex Schultz <aschultz@redhat.com>2019-02-25 16:04:39 -0700
committerAlex Schultz <aschultz@redhat.com>2019-03-12 18:24:29 +0000
commit78c819d6232b3fa5c6fb6aa5ea85a54c596f0b56 (patch)
tree1bf168eae2fb5f47b01cccb2677c94a82a406439 /kolla
parent3e5d8e2653db1c6c28cb428f81cd0bc332c623c3 (diff)
downloadkolla-78c819d6232b3fa5c6fb6aa5ea85a54c596f0b56.tar.gz
kolla-78c819d6232b3fa5c6fb6aa5ea85a54c596f0b56.zip
Add distro_package_manager configuration
Add configuration to allow the switch between dnf/yum or provide an alternative package manager. Change-Id: I913769fcf5875a12b4561958cf7c90b74cd116ea
Diffstat (limited to 'kolla')
-rwxr-xr-xkolla/common/config.py5
-rwxr-xr-xkolla/image/build.py13
-rw-r--r--kolla/tests/test_build.py46
3 files changed, 64 insertions, 0 deletions
diff --git a/kolla/common/config.py b/kolla/common/config.py
index 05ccb13e0..e364ae290 100755
--- a/kolla/common/config.py
+++ b/kolla/common/config.py
@@ -266,6 +266,11 @@ _BASE_OPTS = [
cfg.StrOpt('maintainer',
default='Kolla Project (https://launchpad.net/kolla)',
help='Content of the maintainer label'),
+ cfg.StrOpt('distro_package_manager', default=None,
+ help=('Use this parameter to override the default package '
+ 'manager used by kolla. For example, if you want to use '
+ 'yum on a system with dnf, set this to yum which will '
+ 'use yum command in the build process')),
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 '
diff --git a/kolla/image/build.py b/kolla/image/build.py
index 624db3406..7c85f8cdc 100755
--- a/kolla/image/build.py
+++ b/kolla/image/build.py
@@ -29,6 +29,7 @@ import tempfile
import threading
import time
+from distutils.version import LooseVersion
from distutils.version import StrictVersion
import docker
import git
@@ -701,6 +702,17 @@ class KollaWorker(object):
# Assume worst
self.conf.distro_python_version = "2.7"
+ if self.conf.distro_package_manager is not None:
+ package_manager = self.conf.distro_package_manager
+ elif self.base in rh_base:
+ if LooseVersion(self.base_tag) >= LooseVersion('8'):
+ package_manager = 'dnf'
+ else:
+ package_manager = 'yum'
+ elif self.base in deb_base:
+ package_manager = 'apt'
+ self.distro_package_manager = package_manager
+
# Determine base packaging type for use in Dockerfiles.
if self.conf.base_package_type:
self.base_package_type = self.conf.base_package_type
@@ -917,6 +929,7 @@ class KollaWorker(object):
'image_name': image_name,
'users': self.get_users(),
'distro_python_version': self.distro_python_version,
+ 'distro_package_manager': self.distro_package_manager,
'rpm_setup': self.rpm_setup,
'build_date': build_date}
env = jinja2.Environment( # nosec: not used to render HTML
diff --git a/kolla/tests/test_build.py b/kolla/tests/test_build.py
index 32c5a9928..1fe0f27d3 100644
--- a/kolla/tests/test_build.py
+++ b/kolla/tests/test_build.py
@@ -421,6 +421,52 @@ class KollaWorkerTest(base.TestCase):
kolla = build.KollaWorker(self.conf)
self.assertEqual('2.7', kolla.distro_python_version)
+ def test_build_distro_package_manager(self):
+ """check distro_package_manager conf value is taken"""
+ self.conf.set_override('distro_package_manager', 'foo')
+ kolla = build.KollaWorker(self.conf)
+ self.assertEqual('foo', kolla.distro_package_manager)
+
+ def test_build_distro_package_manager_rhel8(self):
+ """check distro_package_manager dnf for rhel8"""
+ self.conf.set_override('base', 'rhel')
+ self.conf.set_override('base_tag', '8')
+ kolla = build.KollaWorker(self.conf)
+ self.assertEqual('dnf', kolla.distro_package_manager)
+
+ def test_build_distro_package_manager_rhel8_minor(self):
+ """check distro_package_manager dnf for rhel8"""
+ self.conf.set_override('base', 'rhel')
+ self.conf.set_override('base_tag', '8.1.2')
+ kolla = build.KollaWorker(self.conf)
+ self.assertEqual('dnf', kolla.distro_package_manager)
+
+ def test_build_distro_package_manager_rhel7(self):
+ """check distro_package_manager yum for rhel7"""
+ self.conf.set_override('base', 'rhel')
+ self.conf.set_override('base_tag', '7')
+ kolla = build.KollaWorker(self.conf)
+ self.assertEqual('yum', kolla.distro_package_manager)
+
+ def test_build_distro_package_manager_rhel7_minor(self):
+ """check distro_package_manager yum for rhel7"""
+ self.conf.set_override('base', 'rhel')
+ self.conf.set_override('base_tag', '7.6.1801')
+ kolla = build.KollaWorker(self.conf)
+ self.assertEqual('yum', kolla.distro_package_manager)
+
+ def test_build_distro_package_manager_debian(self):
+ """check distro_package_manager apt for debian"""
+ self.conf.set_override('base', 'debian')
+ kolla = build.KollaWorker(self.conf)
+ self.assertEqual('apt', kolla.distro_package_manager)
+
+ def test_build_distro_package_manager_ubuntu(self):
+ """check distro_package_manager apt for ubuntu"""
+ self.conf.set_override('base', 'ubuntu')
+ kolla = build.KollaWorker(self.conf)
+ self.assertEqual('apt', kolla.distro_package_manager)
+
def test_base_package_type(self):
"""check base_package_type conf value is taken"""
self.conf.set_override('base_package_type', 'pip')