Add excludes to kolla builder

Adds ability to exclude specific containers from the container build
process.

Change-Id: I06704f825f73576d40399b672f3ad3e4ed0ff752
This commit is contained in:
Alex Schultz 2018-12-11 16:47:22 -07:00
parent 97987c3ce3
commit d8de81fadd
2 changed files with 28 additions and 3 deletions

View File

@ -431,7 +431,7 @@ class KollaImageBuilder(base.BaseImageManager):
result.append(entry)
return result
def build_images(self, kolla_config_files=None):
def build_images(self, kolla_config_files=None, excludes=[]):
cmd = ['kolla-build']
if kolla_config_files:
@ -442,11 +442,13 @@ class KollaImageBuilder(base.BaseImageManager):
container_images = self.load_config_files(self.CONTAINER_IMAGES) or []
container_images.sort(key=lambda i: i.get('imagename'))
for i in container_images:
# Do not attempt to build containers that are not from kolla
# Do not attempt to build containers that are not from kolla or
# are in our exclude list
if not i.get('image_source', '') == 'kolla':
continue
image = self.imagename_to_regex(i.get('imagename'))
if image:
# Make sure the image was properly parsed and not purposely skipped
if image and image not in excludes:
cmd.append(image)
self.logger.info('Running %s' % ' '.join(cmd))

View File

@ -138,6 +138,29 @@ class TestKollaImageBuilder(base.TestCase):
'kolla-build',
], env=env, stdout=-1)
@mock.patch('tripleo_common.image.base.open',
mock.mock_open(read_data=filedata), create=True)
@mock.patch('os.path.isfile', return_value=True)
@mock.patch('subprocess.Popen')
def test_build_images_exclude(self, mock_popen, mock_path):
process = mock.Mock()
process.returncode = 0
process.communicate.return_value = 'done', ''
mock_popen.return_value = process
builder = kb.KollaImageBuilder(self.filelist)
self.assertEqual('done', builder.build_images(['kolla-config.conf'],
['nova-compute']))
env = os.environ.copy()
mock_popen.assert_called_once_with([
'kolla-build',
'--config-file',
'kolla-config.conf',
'nova-libvirt',
'heat-docker-agents-centos',
'image-with-missing-tag',
], env=env, stdout=-1)
@mock.patch('subprocess.Popen')
def test_build_images_fail(self, mock_popen):
process = mock.Mock()