Add excludes to kolla builder
Adds ability to exclude specific containers from the container build process. Change-Id: I06704f825f73576d40399b672f3ad3e4ed0ff752
This commit is contained in:
@@ -431,7 +431,7 @@ class KollaImageBuilder(base.BaseImageManager):
|
|||||||
result.append(entry)
|
result.append(entry)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def build_images(self, kolla_config_files=None):
|
def build_images(self, kolla_config_files=None, excludes=[]):
|
||||||
|
|
||||||
cmd = ['kolla-build']
|
cmd = ['kolla-build']
|
||||||
if kolla_config_files:
|
if kolla_config_files:
|
||||||
@@ -442,11 +442,13 @@ class KollaImageBuilder(base.BaseImageManager):
|
|||||||
container_images = self.load_config_files(self.CONTAINER_IMAGES) or []
|
container_images = self.load_config_files(self.CONTAINER_IMAGES) or []
|
||||||
container_images.sort(key=lambda i: i.get('imagename'))
|
container_images.sort(key=lambda i: i.get('imagename'))
|
||||||
for i in container_images:
|
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':
|
if not i.get('image_source', '') == 'kolla':
|
||||||
continue
|
continue
|
||||||
image = self.imagename_to_regex(i.get('imagename'))
|
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)
|
cmd.append(image)
|
||||||
|
|
||||||
self.logger.info('Running %s' % ' '.join(cmd))
|
self.logger.info('Running %s' % ' '.join(cmd))
|
||||||
|
@@ -138,6 +138,29 @@ class TestKollaImageBuilder(base.TestCase):
|
|||||||
'kolla-build',
|
'kolla-build',
|
||||||
], env=env, stdout=-1)
|
], 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')
|
@mock.patch('subprocess.Popen')
|
||||||
def test_build_images_fail(self, mock_popen):
|
def test_build_images_fail(self, mock_popen):
|
||||||
process = mock.Mock()
|
process = mock.Mock()
|
||||||
|
Reference in New Issue
Block a user