New command "overcloud container image upload"
This is the container image equivalent to the "overcloud image upload" command. It wraps tripleo-common logic which has existed for some time now[1]. The configuration file used in CI is also in tripleo-common [2] and the existence of this command will allow the custom python[3] to be replaced with a simple command invocation. The same configuration file format will be used to implement another new command "overcloud container image build". [1] http://git.openstack.org/cgit/openstack/tripleo-common/tree/tripleo_common/image/image_uploader.py [2] http://git.openstack.org/cgit/openstack/tripleo-common/tree/contrib/overcloud_containers.yaml [3] http://git.openstack.org/cgit/openstack/tripleo-quickstart-extras/tree/roles/overcloud-prep-containers/templates/upload_images_to_local_registry.py.j2 Change-Id: Id505b57698b6a15c62494764b2d9eca1933e63f1
This commit is contained in:
parent
62153e7540
commit
efedf4bb7c
@ -62,6 +62,7 @@ openstack.tripleoclient.v1 =
|
||||
baremetal_configure_ready_state = tripleoclient.v1.baremetal:ConfigureReadyState
|
||||
baremetal_configure_boot = tripleoclient.v1.baremetal:ConfigureBaremetalBoot
|
||||
overcloud_netenv_validate = tripleoclient.v1.overcloud_netenv_validate:ValidateOvercloudNetenv
|
||||
overcloud_container_image_upload = tripleoclient.v1.container_image:UploadImage
|
||||
overcloud_delete = tripleoclient.v1.overcloud_delete:DeleteOvercloud
|
||||
overcloud_deploy = tripleoclient.v1.overcloud_deploy:DeployOvercloud
|
||||
overcloud_image_build = tripleoclient.v1.overcloud_image:BuildOvercloudImage
|
||||
|
@ -0,0 +1,60 @@
|
||||
# Copyright 2015 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
import mock
|
||||
|
||||
from tripleoclient.tests.v1.test_plugin import TestPluginV1
|
||||
from tripleoclient.v1 import container_image
|
||||
|
||||
|
||||
class TestContainerImageUpload(TestPluginV1):
|
||||
|
||||
def setUp(self):
|
||||
super(TestContainerImageUpload, self).setUp()
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd = container_image.UploadImage(self.app, None)
|
||||
|
||||
@mock.patch('tripleo_common.image.image_uploader.ImageUploadManager',
|
||||
autospec=True)
|
||||
def test_container_image_upload_noargs(self, mock_manager):
|
||||
arglist = []
|
||||
verifylist = []
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
mock_manager.assert_called_once_with([])
|
||||
mock_manager.return_value.upload.assert_called_once_with()
|
||||
|
||||
@mock.patch('tripleo_common.image.image_uploader.ImageUploadManager',
|
||||
autospec=True)
|
||||
def test_container_image_upload_conf_files(self, mock_manager):
|
||||
arglist = [
|
||||
'--config-file',
|
||||
'/tmp/foo.yaml',
|
||||
'--config-file',
|
||||
'/tmp/bar.yaml'
|
||||
]
|
||||
verifylist = []
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
mock_manager.assert_called_once_with(
|
||||
['/tmp/foo.yaml', '/tmp/bar.yaml'])
|
||||
mock_manager.return_value.upload.assert_called_once_with()
|
47
tripleoclient/v1/container_image.py
Normal file
47
tripleoclient/v1/container_image.py
Normal file
@ -0,0 +1,47 @@
|
||||
# Copyright 2015 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
import logging
|
||||
|
||||
from osc_lib.command import command
|
||||
from osc_lib.i18n import _
|
||||
|
||||
from tripleo_common.image import image_uploader
|
||||
|
||||
|
||||
class UploadImage(command.Command):
|
||||
"""Push overcloud container images to registries."""
|
||||
log = logging.getLogger(__name__ + ".UploadImage")
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(UploadImage, 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 image build. May be "
|
||||
"specified multiple times. Order is preserved, and later "
|
||||
"files will override some options in previous files. "
|
||||
"Other options will append."),
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
self.log.debug("take_action(%s)" % parsed_args)
|
||||
uploader = image_uploader.ImageUploadManager(
|
||||
parsed_args.config_files)
|
||||
uploader.upload()
|
Loading…
x
Reference in New Issue
Block a user