New command "overcloud container image build"
This command receives the same --config-file argument as "overcloud container image upload" and invokes kolla-build to build the images specified in that file. It is also possible to specify --kolla-config-file multiple times to control the behaviour of kolla-build. Change-Id: If06a941eaf8d92c29ed84387c4f040866cf07cfa Depends-On: I061f626fdb3d71613aa23436bf6c53cf4de62213
This commit is contained in:
parent
27d43fffff
commit
5ae4769354
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
New command ``overcloud container image upload``. This is the container
|
||||||
|
image equivalent to the ``overcloud image upload`` command.
|
||||||
|
- |
|
||||||
|
New command ``overcloud container image build``. This command receives the
|
||||||
|
same ``--config-file`` argument as ``overcloud container image upload`` and
|
||||||
|
invokes kolla-build to build the images specified in that file.
|
@ -63,6 +63,7 @@ openstack.tripleoclient.v1 =
|
|||||||
baremetal_configure_boot = tripleoclient.v1.baremetal:ConfigureBaremetalBoot
|
baremetal_configure_boot = tripleoclient.v1.baremetal:ConfigureBaremetalBoot
|
||||||
overcloud_netenv_validate = tripleoclient.v1.overcloud_netenv_validate:ValidateOvercloudNetenv
|
overcloud_netenv_validate = tripleoclient.v1.overcloud_netenv_validate:ValidateOvercloudNetenv
|
||||||
overcloud_container_image_upload = tripleoclient.v1.container_image:UploadImage
|
overcloud_container_image_upload = tripleoclient.v1.container_image:UploadImage
|
||||||
|
overcloud_container_image_build = tripleoclient.v1.container_image:BuildImage
|
||||||
overcloud_delete = tripleoclient.v1.overcloud_delete:DeleteOvercloud
|
overcloud_delete = tripleoclient.v1.overcloud_delete:DeleteOvercloud
|
||||||
overcloud_credentials = tripleoclient.v1.overcloud_credentials:OvercloudCredentials
|
overcloud_credentials = tripleoclient.v1.overcloud_credentials:OvercloudCredentials
|
||||||
overcloud_deploy = tripleoclient.v1.overcloud_deploy:DeployOvercloud
|
overcloud_deploy = tripleoclient.v1.overcloud_deploy:DeployOvercloud
|
||||||
|
@ -58,3 +58,48 @@ class TestContainerImageUpload(TestPluginV1):
|
|||||||
mock_manager.assert_called_once_with(
|
mock_manager.assert_called_once_with(
|
||||||
['/tmp/foo.yaml', '/tmp/bar.yaml'])
|
['/tmp/foo.yaml', '/tmp/bar.yaml'])
|
||||||
mock_manager.return_value.upload.assert_called_once_with()
|
mock_manager.return_value.upload.assert_called_once_with()
|
||||||
|
|
||||||
|
|
||||||
|
class TestContainerImageBuild(TestPluginV1):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(TestContainerImageBuild, self).setUp()
|
||||||
|
|
||||||
|
# Get the command object to test
|
||||||
|
self.cmd = container_image.BuildImage(self.app, None)
|
||||||
|
|
||||||
|
@mock.patch('tripleo_common.image.kolla_builder.KollaImageBuilder',
|
||||||
|
autospec=True)
|
||||||
|
def test_container_image_build_noargs(self, mock_builder):
|
||||||
|
arglist = []
|
||||||
|
verifylist = []
|
||||||
|
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
mock_builder.assert_called_once_with([])
|
||||||
|
mock_builder.return_value.build_images.assert_called_once_with([])
|
||||||
|
|
||||||
|
@mock.patch('tripleo_common.image.kolla_builder.KollaImageBuilder',
|
||||||
|
autospec=True)
|
||||||
|
def test_container_image_build(self, mock_builder):
|
||||||
|
arglist = [
|
||||||
|
'--config-file',
|
||||||
|
'/tmp/foo.yaml',
|
||||||
|
'--config-file',
|
||||||
|
'/tmp/bar.yaml',
|
||||||
|
'--kolla-config-file',
|
||||||
|
'/tmp/kolla.conf'
|
||||||
|
]
|
||||||
|
verifylist = []
|
||||||
|
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
mock_builder.assert_called_once_with([
|
||||||
|
'/tmp/foo.yaml', '/tmp/bar.yaml'])
|
||||||
|
mock_builder.return_value.build_images.assert_called_once_with([
|
||||||
|
'/tmp/kolla.conf'
|
||||||
|
])
|
||||||
|
@ -19,6 +19,7 @@ from osc_lib.command import command
|
|||||||
from osc_lib.i18n import _
|
from osc_lib.i18n import _
|
||||||
|
|
||||||
from tripleo_common.image import image_uploader
|
from tripleo_common.image import image_uploader
|
||||||
|
from tripleo_common.image import kolla_builder
|
||||||
|
|
||||||
|
|
||||||
class UploadImage(command.Command):
|
class UploadImage(command.Command):
|
||||||
@ -45,3 +46,40 @@ class UploadImage(command.Command):
|
|||||||
uploader = image_uploader.ImageUploadManager(
|
uploader = image_uploader.ImageUploadManager(
|
||||||
parsed_args.config_files)
|
parsed_args.config_files)
|
||||||
uploader.upload()
|
uploader.upload()
|
||||||
|
|
||||||
|
|
||||||
|
class BuildImage(command.Command):
|
||||||
|
"""Build overcloud container images with kolla-build."""
|
||||||
|
|
||||||
|
auth_required = False
|
||||||
|
log = logging.getLogger(__name__ + ".BuildImage")
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super(BuildImage, self).get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
"--config-file",
|
||||||
|
dest="config_files",
|
||||||
|
metavar='<yaml config file>',
|
||||||
|
default=[],
|
||||||
|
action="append",
|
||||||
|
help=_("YAML config file specifying the images to build. May be "
|
||||||
|
"specified multiple times. Order is preserved, and later "
|
||||||
|
"files will override some options in previous files. "
|
||||||
|
"Other options will append."),
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--kolla-config-file",
|
||||||
|
dest="kolla_config_files",
|
||||||
|
metavar='<config file>',
|
||||||
|
default=[],
|
||||||
|
action="append",
|
||||||
|
help=_("Path to a Kolla config file to use. Multiple config files "
|
||||||
|
"can be specified, with values in later files taking "
|
||||||
|
"precedence."),
|
||||||
|
)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
self.log.debug("take_action(%s)" % parsed_args)
|
||||||
|
builder = kolla_builder.KollaImageBuilder(parsed_args.config_files)
|
||||||
|
builder.build_images(parsed_args.kolla_config_files)
|
||||||
|
Loading…
Reference in New Issue
Block a user