2017-03-15 19:38:59 +00:00
|
|
|
# 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
|
2017-03-22 11:19:11 +13:00
|
|
|
from tripleo_common.image import kolla_builder
|
2017-03-15 19:38:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
class UploadImage(command.Command):
|
|
|
|
"""Push overcloud container images to registries."""
|
2017-04-10 17:58:25 +02:00
|
|
|
|
|
|
|
auth_required = False
|
2017-03-15 19:38:59 +00:00
|
|
|
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",
|
2017-06-20 08:41:23 -06:00
|
|
|
required=True,
|
2017-03-15 19:38:59 +00:00
|
|
|
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()
|
2017-03-22 11:19:11 +13:00
|
|
|
|
|
|
|
|
|
|
|
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",
|
2017-06-20 08:41:23 -06:00
|
|
|
required=True,
|
2017-03-22 11:19:11 +13:00
|
|
|
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",
|
2017-06-20 08:41:23 -06:00
|
|
|
required=True,
|
2017-03-22 11:19:11 +13:00
|
|
|
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)
|