Fix tcib build
The tcib build process assumes that all the container configs exist in a
'tcib' folder as defined via --config-path. This change documents this
requirement and additionally we've hard coded 'container-images' in
the image config to exclude this folder however if you define a
custom --config-path, this fails. This change removes the hard coded
'container-images' while documenting the 'tcib' requirement.
Change-Id: Iad987da5bedc30da7118a3aec5dbe96cd8d71d1e
Closes-Bug: #1897616
(cherry picked from commit fe7380ddff
)
This commit is contained in:
parent
99c9f2ddbd
commit
7700507fc7
|
@ -213,6 +213,15 @@ class TestContainerImages(deploy_fakes.TestDeployOvercloud):
|
||||||
|
|
||||||
self.check_parser(self.cmd, arglist, verifylist)
|
self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
def test_image_build_config_dir(self):
|
||||||
|
arglist = ["--config-file", "config.yaml", "--config-path", "/foo"]
|
||||||
|
verifylist = [("config_file", "config.yaml"), ("config_path", "/foo")]
|
||||||
|
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
self._take_action(parsed_args=parsed_args)
|
||||||
|
self.assertEqual(self.cmd.tcib_config_path, '/foo/tcib')
|
||||||
|
|
||||||
def test_image_build_failure_no_config_dir(self):
|
def test_image_build_failure_no_config_dir(self):
|
||||||
arglist = ["--config-path", "not-a-path"]
|
arglist = ["--config-path", "not-a-path"]
|
||||||
verifylist = [
|
verifylist = [
|
||||||
|
@ -225,6 +234,28 @@ class TestContainerImages(deploy_fakes.TestDeployOvercloud):
|
||||||
mock_isfile.return_value = True
|
mock_isfile.return_value = True
|
||||||
self.assertRaises(IOError, self.cmd.take_action, parsed_args)
|
self.assertRaises(IOError, self.cmd.take_action, parsed_args)
|
||||||
|
|
||||||
|
def test_process_images(self):
|
||||||
|
rtn_value = {'yay': 'values'}
|
||||||
|
arglist = ["--config-path", "foobar/"]
|
||||||
|
verifylist = [
|
||||||
|
("config_path", "foobar/"),
|
||||||
|
]
|
||||||
|
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
expected_images = ['foo', 'foobar']
|
||||||
|
image_configs = {}
|
||||||
|
self.cmd.tcib_config_path = '/foo/tcib'
|
||||||
|
with mock.patch("tripleoclient.v1.tripleo_container_image.Build"
|
||||||
|
".find_image", autospec=True) as mock_find_image:
|
||||||
|
|
||||||
|
mock_find_image.return_value = rtn_value
|
||||||
|
cfgs = self.cmd.process_images(expected_images, parsed_args,
|
||||||
|
image_configs)
|
||||||
|
mock_find_image.assert_called_once_with(self.cmd, 'foo',
|
||||||
|
'/foo/tcib', 'ubi8')
|
||||||
|
self.assertEqual(cfgs, {'foo': rtn_value})
|
||||||
|
|
||||||
|
|
||||||
class TestContainerImagesHotfix(deploy_fakes.TestDeployOvercloud):
|
class TestContainerImagesHotfix(deploy_fakes.TestDeployOvercloud):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|
|
@ -98,8 +98,9 @@ class Build(command.Command):
|
||||||
default=BASE_PATH,
|
default=BASE_PATH,
|
||||||
help=_(
|
help=_(
|
||||||
"Base configuration path. This is the base path for all "
|
"Base configuration path. This is the base path for all "
|
||||||
"container-image files. If this option is set, the "
|
"container-image files. The defined containers must reside "
|
||||||
"default path for <config-file> will be modified. "
|
"within a 'tcib' folder that is in this path. If this option "
|
||||||
|
"is set, the default path for <config-file> will be modified. "
|
||||||
"(default: %(default)s)"
|
"(default: %(default)s)"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -365,8 +366,10 @@ class Build(command.Command):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
image_configs = collections.OrderedDict()
|
image_configs = collections.OrderedDict()
|
||||||
|
config_path_base = os.path.basename(
|
||||||
|
os.path.abspath(parsed_args.config_path))
|
||||||
for image in expected_images:
|
for image in expected_images:
|
||||||
if image != "container-images" and image not in image_configs:
|
if (image != config_path_base and image not in image_configs):
|
||||||
self.log.debug("processing image configs".format(image))
|
self.log.debug("processing image configs".format(image))
|
||||||
image_config = self.find_image(
|
image_config = self.find_image(
|
||||||
image,
|
image,
|
||||||
|
@ -399,6 +402,7 @@ class Build(command.Command):
|
||||||
self.tcib_config_path = os.path.join(
|
self.tcib_config_path = os.path.join(
|
||||||
self.config_path, DEFAULT_TCIB_CONFIG_BASE
|
self.config_path, DEFAULT_TCIB_CONFIG_BASE
|
||||||
)
|
)
|
||||||
|
|
||||||
if not os.path.isdir(self.tcib_config_path):
|
if not os.path.isdir(self.tcib_config_path):
|
||||||
raise IOError(
|
raise IOError(
|
||||||
"Configuration directory {} was not found.".format(
|
"Configuration directory {} was not found.".format(
|
||||||
|
|
Loading…
Reference in New Issue