aboutsummaryrefslogtreecommitdiff
path: root/kolla
diff options
context:
space:
mode:
Diffstat (limited to 'kolla')
-rwxr-xr-xkolla/common/config.py9
-rwxr-xr-xkolla/image/build.py8
-rw-r--r--kolla/tests/test_build.py53
3 files changed, 55 insertions, 15 deletions
diff --git a/kolla/common/config.py b/kolla/common/config.py
index 42eef7aaa..3ef4819be 100755
--- a/kolla/common/config.py
+++ b/kolla/common/config.py
@@ -963,7 +963,7 @@ USERS = {
}
-def get_source_opts(type_=None, location=None, reference=None):
+def get_source_opts(type_=None, location=None, reference=None, enabled=True):
return [cfg.StrOpt('type', choices=['local', 'git', 'url'],
default=type_,
help='Source location type'),
@@ -971,7 +971,9 @@ def get_source_opts(type_=None, location=None, reference=None):
help='The location for source install'),
cfg.StrOpt('reference', default=reference,
help=('Git reference to pull, commit sha, tag '
- 'or branch name'))]
+ 'or branch name')),
+ cfg.BoolOpt('enabled', default=enabled,
+ help=('Whether the source is enabled'))]
def get_user_opts(uid, gid, group):
@@ -998,7 +1000,8 @@ def gen_all_source_opts():
type_ = params['type']
location = params['location']
reference = params.get('reference')
- yield name, get_source_opts(type_, location, reference)
+ enabled = params.get('enabled', True)
+ yield name, get_source_opts(type_, location, reference, enabled)
def list_opts():
diff --git a/kolla/image/build.py b/kolla/image/build.py
index c9c2a60bd..583c22f18 100755
--- a/kolla/image/build.py
+++ b/kolla/image/build.py
@@ -362,6 +362,10 @@ class BuildTask(DockerTask):
return followups
def process_source(self, image, source):
+ if not source['enabled']:
+ self.logger.debug("Skipping disabled source %s", source['name'])
+ return
+
dest_archive = os.path.join(image.path, source['name'] + '-archive')
if source.get('type') == 'url':
@@ -459,7 +463,8 @@ class BuildTask(DockerTask):
archive_path = self.process_source(image, item)
if image.status in STATUS_ERRORS:
raise ArchivingError
- archives.append(archive_path)
+ if archive_path:
+ archives.append(archive_path)
if archives:
for archive in archives:
with tarfile.open(archive, 'r') as archive_tar:
@@ -1207,6 +1212,7 @@ class KollaWorker(object):
installation['name'] = section
if installation['type'] == 'git':
installation['reference'] = self.conf[section]['reference']
+ installation['enabled'] = self.conf[section]['enabled']
return installation
all_sections = (set(self.conf._groups.keys()) |
diff --git a/kolla/tests/test_build.py b/kolla/tests/test_build.py
index 0200fadd7..6174d5dd8 100644
--- a/kolla/tests/test_build.py
+++ b/kolla/tests/test_build.py
@@ -254,7 +254,8 @@ class TasksTest(base.TestCase):
self.image.source = {
'source': 'http://fake/source',
'type': 'url',
- 'name': 'fake-image-base'
+ 'name': 'fake-image-base',
+ 'enabled': True
}
push_queue = mock.Mock()
builder = build.BuildTask(self.conf, self.image, push_queue)
@@ -276,17 +277,21 @@ class TasksTest(base.TestCase):
def test_process_source(self, mock_get, mock_client,
mock_rmtree, mock_copyfile, mock_utime):
for source in [{'source': 'http://fake/source1', 'type': 'url',
- 'name': 'fake-image-base1',
- 'reference': 'http://fake/reference1'},
+ 'name': 'fake-image-base1',
+ 'reference': 'http://fake/reference1',
+ 'enabled': True},
{'source': 'http://fake/source2', 'type': 'git',
- 'name': 'fake-image-base2',
- 'reference': 'http://fake/reference2'},
+ 'name': 'fake-image-base2',
+ 'reference': 'http://fake/reference2',
+ 'enabled': True},
{'source': 'http://fake/source3', 'type': 'local',
- 'name': 'fake-image-base3',
- 'reference': 'http://fake/reference3'},
+ 'name': 'fake-image-base3',
+ 'reference': 'http://fake/reference3',
+ 'enabled': True},
{'source': 'http://fake/source4', 'type': None,
- 'name': 'fake-image-base4',
- 'reference': 'http://fake/reference4'}]:
+ 'name': 'fake-image-base4',
+ 'reference': 'http://fake/reference4',
+ 'enabled': True}]:
self.image.source = source
push_queue = mock.Mock()
builder = build.BuildTask(self.conf, self.image, push_queue)
@@ -305,7 +310,8 @@ class TasksTest(base.TestCase):
mock_path_exists):
source = {'source': 'http://fake/source1', 'type': 'git',
'name': 'fake-image1',
- 'reference': 'fake/reference1'}
+ 'reference': 'fake/reference1',
+ 'enabled': True}
self.image.source = source
self.image.path = "fake_image_path"
@@ -385,7 +391,8 @@ class KollaWorkerTest(base.TestCase):
'name': 'neutron-server-plugin-networking-arista',
'reference': 'master',
'source': 'https://opendev.org/x/networking-arista',
- 'type': 'git'
+ 'type': 'git',
+ 'enabled': True
}
found = False
@@ -399,6 +406,30 @@ class KollaWorkerTest(base.TestCase):
if not found:
self.fail('Can not find the expected neutron arista plugin')
+ def test_build_image_list_skips_disabled_plugins(self):
+
+ self.conf.set_override('install_type', 'source')
+ self.conf.set_override('enabled', False,
+ 'neutron-base-plugin-networking-baremetal')
+
+ kolla = build.KollaWorker(self.conf)
+ kolla.setup_working_dir()
+ kolla.find_dockerfiles()
+ kolla.create_dockerfiles()
+ kolla.build_image_list()
+ disabled_plugin = 'neutron-base-plugin-networking-baremetal'
+
+ found = False
+ for image in kolla.images:
+ if image.name == 'neutron-server':
+ for plugin in image.plugins:
+ if plugin == disabled_plugin:
+ found = True
+ break
+ break
+ if found:
+ self.fail('Found disabled neutron networking-baremetal plugin')
+
def test_build_image_list_plugin_parsing(self):
"""Ensure regex used to parse plugins adds them to the correct image"""
self.conf.set_override('install_type', 'source')