Use container_images_file for all image prepare
The recently merged change Ie8543bed3363aac539cfd35e04e8dfaaa166ebc3 added five new options to undercloud.conf to drive the container prepare during undercloud install. However this is not nearly as flexible as the prepare workflow for overcloud deploy, which can have multiple entries in the ContainerImagePrepare parameter list. This change removes those new options, and uses the specified container_images_file file as the source for the ContainerImagePrepare parameter *or* the container image parameters. If no file is specified, the environment has a default ContainerImagePrepare parameter set which will result in a working undercloud based on the defaults in kolla_builder. Change-Id: Ic1e6eb5ff0aaeaded279c97139adc9fdebb12857 Blueprint: containerized-undercloud
This commit is contained in:
parent
e3695e44b5
commit
5741603308
@ -1,16 +1,8 @@
|
|||||||
---
|
---
|
||||||
features:
|
features:
|
||||||
- |
|
- |
|
||||||
Parameters for undercloud container images can now be populated during the
|
|
||||||
run of `openstack undercloud install --use-heat`. This is controlled by the
|
|
||||||
new `undercloud.conf` options:
|
|
||||||
|
|
||||||
* container_image_namespace
|
If no undercloud.conf `container_images_file` is set then `openstack
|
||||||
* container_image_name_prefix
|
undercloud install --use-heat` will deploy an undercloud with the latest
|
||||||
* container_image_name_suffix
|
containers as specified by the defaults. This allows the
|
||||||
* container_image_tag
|
`container_images_file` option to be not mandatory.
|
||||||
* container_image_tag_from_label
|
|
||||||
|
|
||||||
If the option `container_images_file` is set then the above options are
|
|
||||||
ignored. Generally default values will be sufficient, resulting in the
|
|
||||||
undercloud being deployed with the recommended images using versioned tags.
|
|
||||||
|
@ -25,6 +25,8 @@ import os
|
|||||||
import tempfile
|
import tempfile
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
from tripleo_common.image import kolla_builder
|
||||||
|
|
||||||
from tripleoclient.tests import base
|
from tripleoclient.tests import base
|
||||||
from tripleoclient.v1 import undercloud_config
|
from tripleoclient.v1 import undercloud_config
|
||||||
|
|
||||||
@ -248,39 +250,43 @@ class TestContainerImageConfig(base.TestCase):
|
|||||||
super(TestContainerImageConfig, self).setUp()
|
super(TestContainerImageConfig, self).setUp()
|
||||||
conf_keys = (
|
conf_keys = (
|
||||||
'container_images_file',
|
'container_images_file',
|
||||||
'container_image_namespace',
|
|
||||||
'container_image_name_prefix',
|
|
||||||
'container_image_name_suffix',
|
|
||||||
'container_image_tag',
|
|
||||||
'container_image_tag_from_label'
|
|
||||||
)
|
)
|
||||||
self.conf = mock.Mock(**{key: getattr(undercloud_config.CONF, key)
|
self.conf = mock.Mock(**{key: getattr(undercloud_config.CONF, key)
|
||||||
for key in conf_keys})
|
for key in conf_keys})
|
||||||
|
|
||||||
def test_mandatory_conf(self):
|
|
||||||
self.assertRaises(RuntimeError,
|
|
||||||
undercloud_config._container_images_config,
|
|
||||||
self.conf, [], {})
|
|
||||||
|
|
||||||
def test_defaults(self):
|
def test_defaults(self):
|
||||||
env = {}
|
env = {}
|
||||||
deploy_args = []
|
deploy_args = []
|
||||||
self.conf.container_image_namespace = 'foo'
|
cip_default = getattr(kolla_builder,
|
||||||
|
'CONTAINER_IMAGE_PREPARE_PARAM', None)
|
||||||
|
self.addCleanup(setattr, kolla_builder,
|
||||||
|
'CONTAINER_IMAGE_PREPARE_PARAM', cip_default)
|
||||||
|
|
||||||
|
setattr(kolla_builder, 'CONTAINER_IMAGE_PREPARE_PARAM', [{
|
||||||
|
'set': {
|
||||||
|
'namespace': 'one',
|
||||||
|
'name_prefix': 'two',
|
||||||
|
'name_suffix': 'three',
|
||||||
|
'tag': 'four',
|
||||||
|
},
|
||||||
|
'tag_from_label': 'five',
|
||||||
|
}])
|
||||||
|
|
||||||
undercloud_config._container_images_config(self.conf, deploy_args, env)
|
undercloud_config._container_images_config(self.conf, deploy_args, env)
|
||||||
self.assertEqual([], deploy_args)
|
self.assertEqual([], deploy_args)
|
||||||
cip = env['ContainerImagePrepare'][0]
|
cip = env['ContainerImagePrepare'][0]
|
||||||
|
set = cip['set']
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
'foo', cip['namespace'])
|
'one', set['namespace'])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.conf.container_image_name_prefix, cip['name_prefix'])
|
'two', set['name_prefix'])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.conf.container_image_name_suffix, cip['name_suffix'])
|
'three', set['name_suffix'])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.conf.container_image_tag, cip['tag'])
|
'four', set['tag'])
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.conf.container_image_tag_from_label,
|
'five', cip['tag_from_label'])
|
||||||
cip.get('tag_from_label'))
|
|
||||||
|
|
||||||
def test_container_images_file(self):
|
def test_container_images_file(self):
|
||||||
env = {}
|
env = {}
|
||||||
@ -294,23 +300,21 @@ class TestContainerImageConfig(base.TestCase):
|
|||||||
def test_custom(self):
|
def test_custom(self):
|
||||||
env = {}
|
env = {}
|
||||||
deploy_args = []
|
deploy_args = []
|
||||||
self.conf.container_image_namespace = 'one'
|
with tempfile.NamedTemporaryFile(mode='w') as f:
|
||||||
self.conf.container_image_name_prefix = 'two'
|
yaml.dump({
|
||||||
self.conf.container_image_name_suffix = 'three'
|
'parameter_defaults': {'ContainerImagePrepare': [{
|
||||||
self.conf.container_image_tag = 'four'
|
'set': {
|
||||||
self.conf.container_image_tag_from_label = 'five'
|
'namespace': 'one',
|
||||||
|
'name_prefix': 'two',
|
||||||
|
'name_suffix': 'three',
|
||||||
|
'tag': 'four',
|
||||||
|
},
|
||||||
|
'tag_from_label': 'five',
|
||||||
|
}]}
|
||||||
|
}, f)
|
||||||
|
self.conf.container_images_file = f.name
|
||||||
|
cif_name = f.name
|
||||||
|
|
||||||
undercloud_config._container_images_config(self.conf, deploy_args, env)
|
undercloud_config._container_images_config(
|
||||||
self.assertEqual([], deploy_args)
|
self.conf, deploy_args, env)
|
||||||
|
self.assertEqual(['-e', cif_name], deploy_args)
|
||||||
cip = env['ContainerImagePrepare'][0]
|
|
||||||
self.assertEqual(
|
|
||||||
'one', cip['namespace'])
|
|
||||||
self.assertEqual(
|
|
||||||
'two', cip['name_prefix'])
|
|
||||||
self.assertEqual(
|
|
||||||
'three', cip['name_suffix'])
|
|
||||||
self.assertEqual(
|
|
||||||
'four', cip['tag'])
|
|
||||||
self.assertEqual(
|
|
||||||
'five', cip['tag_from_label'])
|
|
||||||
|
@ -357,32 +357,10 @@ _opts = [
|
|||||||
),
|
),
|
||||||
cfg.StrOpt('container_images_file',
|
cfg.StrOpt('container_images_file',
|
||||||
default='',
|
default='',
|
||||||
help=('Container yaml file with all available images in the '
|
help=('Heat environment file with parameters for all required '
|
||||||
'registry. When not specified, the values provided by '
|
'container images. Or alternatively, parameter '
|
||||||
'this file will be generated using the '
|
'"ContainerImagePrepare" to drive the required image '
|
||||||
'container_image_* options.')
|
'preparation.')),
|
||||||
),
|
|
||||||
cfg.StrOpt('container_image_namespace',
|
|
||||||
default='',
|
|
||||||
help=('Namespace portion of image path, for example: %s' %
|
|
||||||
ci_defaults.get('namespace'))
|
|
||||||
),
|
|
||||||
cfg.StrOpt('container_image_name_prefix',
|
|
||||||
default=ci_defaults.get('name_prefix'),
|
|
||||||
help=('Name prefix of container image names')
|
|
||||||
),
|
|
||||||
cfg.StrOpt('container_image_name_suffix',
|
|
||||||
default=ci_defaults.get('name_suffix'),
|
|
||||||
help=('Name suffix of container image names')
|
|
||||||
),
|
|
||||||
cfg.StrOpt('container_image_tag',
|
|
||||||
default=ci_defaults.get('tag'),
|
|
||||||
help=('Tag of undercloud images to deploy')
|
|
||||||
),
|
|
||||||
cfg.StrOpt('container_image_tag_from_label',
|
|
||||||
default=ci_defaults.get('tag_from_label'),
|
|
||||||
help=('Image label to use to discover versioned tag')
|
|
||||||
),
|
|
||||||
cfg.BoolOpt('enable_ironic',
|
cfg.BoolOpt('enable_ironic',
|
||||||
default=True,
|
default=True,
|
||||||
help=('Whether to enable the ironic service.')),
|
help=('Whether to enable the ironic service.')),
|
||||||
@ -750,19 +728,8 @@ def _write_env_file(env_data,
|
|||||||
def _container_images_config(conf, deploy_args, env_data):
|
def _container_images_config(conf, deploy_args, env_data):
|
||||||
if conf.container_images_file:
|
if conf.container_images_file:
|
||||||
deploy_args += ['-e', conf.container_images_file]
|
deploy_args += ['-e', conf.container_images_file]
|
||||||
elif conf.container_image_namespace:
|
|
||||||
pd = kolla_builder.container_images_prepare_defaults()
|
|
||||||
if conf.container_image_namespace:
|
|
||||||
pd['namespace'] = conf.container_image_namespace
|
|
||||||
if conf.container_image_name_prefix:
|
|
||||||
pd['name_prefix'] = conf.container_image_name_prefix
|
|
||||||
if conf.container_image_name_suffix:
|
|
||||||
pd['name_suffix'] = conf.container_image_name_suffix
|
|
||||||
if conf.container_image_tag:
|
|
||||||
pd['tag'] = conf.container_image_tag
|
|
||||||
if conf.container_image_tag_from_label:
|
|
||||||
pd['tag_from_label'] = conf.container_image_tag_from_label
|
|
||||||
env_data['ContainerImagePrepare'] = [pd]
|
|
||||||
else:
|
else:
|
||||||
raise RuntimeError('Either "container_images_file" or '
|
# no images file was provided. Set a default ContainerImagePrepare
|
||||||
'"container_image_namespace" must be specified.')
|
# parameter to trigger the preparation of the required container list
|
||||||
|
cip = kolla_builder.CONTAINER_IMAGE_PREPARE_PARAM
|
||||||
|
env_data['ContainerImagePrepare'] = cip
|
||||||
|
Loading…
Reference in New Issue
Block a user