2017-03-10 12:12:13 +01:00
|
|
|
# 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
|
|
|
|
import os
|
|
|
|
|
|
|
|
from osc_lib.i18n import _
|
2017-07-26 17:40:46 +02:00
|
|
|
from tripleo_common.utils import config as ooo_config
|
2017-03-10 12:12:13 +01:00
|
|
|
|
2017-11-21 14:27:47 +00:00
|
|
|
from tripleoclient import command
|
|
|
|
|
2017-03-10 12:12:13 +01:00
|
|
|
|
|
|
|
class DownloadConfig(command.Command):
|
|
|
|
"""Download Overcloud Config"""
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__ + ".DownloadConfig")
|
|
|
|
|
|
|
|
def get_parser(self, prog_name):
|
|
|
|
parser = super(DownloadConfig, self).get_parser(prog_name)
|
|
|
|
parser.add_argument(
|
|
|
|
'--name',
|
|
|
|
dest='name',
|
|
|
|
default='overcloud',
|
|
|
|
help=_('The name of the plan, which is used for the object '
|
|
|
|
'storage container, workflow environment and orchestration '
|
|
|
|
'stack names.'),
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
'--config-dir',
|
|
|
|
dest='config_dir',
|
2018-03-07 11:16:24 -08:00
|
|
|
default=os.path.expanduser("~")+'/tripleo-config',
|
2017-03-10 12:12:13 +01:00
|
|
|
help=_('The directory where the configuration files will be '
|
|
|
|
'pushed'),
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
'--config-type',
|
|
|
|
dest='config_type',
|
|
|
|
type=list,
|
2017-07-26 17:40:46 +02:00
|
|
|
default=None,
|
2017-07-14 10:57:14 +01:00
|
|
|
help=_('Type of object config to be extract from the deployment, '
|
|
|
|
'defaults to all keys available'),
|
2017-03-10 12:12:13 +01:00
|
|
|
)
|
2018-03-15 11:18:23 -07:00
|
|
|
parser.add_argument(
|
|
|
|
'--no-preserve-config',
|
|
|
|
dest='preserve_config_dir',
|
|
|
|
action='store_false',
|
|
|
|
default=True,
|
|
|
|
help=('If specified, will delete and recreate the --config-dir '
|
|
|
|
'if it already exists. Default is to use the existing dir '
|
|
|
|
'location and overwrite files. Files in --config-dir not '
|
|
|
|
'from the stack will be preserved by default.')
|
|
|
|
)
|
2017-03-10 12:12:13 +01:00
|
|
|
return parser
|
|
|
|
|
|
|
|
def take_action(self, parsed_args):
|
|
|
|
self.log.debug("take_action(%s)" % parsed_args)
|
2017-07-26 17:40:46 +02:00
|
|
|
# Get clients
|
2017-03-10 12:12:13 +01:00
|
|
|
clients = self.app.client_manager
|
|
|
|
|
|
|
|
name = parsed_args.name
|
|
|
|
config_dir = parsed_args.config_dir
|
2017-07-26 17:40:46 +02:00
|
|
|
config_type = parsed_args.config_type
|
2018-03-15 11:18:23 -07:00
|
|
|
preserve_config_dir = parsed_args.preserve_config_dir
|
2017-07-26 17:40:46 +02:00
|
|
|
# Get config
|
|
|
|
config = ooo_config.Config(clients.orchestration)
|
2018-03-15 11:18:23 -07:00
|
|
|
config_path = config.download_config(name, config_dir, config_type,
|
|
|
|
preserve_config_dir)
|
2017-10-24 11:33:45 +02:00
|
|
|
print("The TripleO configuration has been successfully generated "
|
|
|
|
"into: {0}".format(config_path))
|