python-tripleoclient/tripleoclient/config/base.py
James Slagle 9f1c1ccce6 Use a consistent working directory for tripleo deploy
When
https://review.opendev.org/c/openstack/python-tripleoclient/+/775302
merged, it changed the function signature of
utils.archive_deploy_artifacts, but the tripleo deploy code was not
updated to pass the right arguments. This caused the templates directory
to be considered the working directory and the artifact tarball was
generated in that directory, and then promptly deleted during the
cleanup phase.

This patch updates tripleo deploy to pass the right arguments to
archive_deploy_artifacts, and also use a consistent working directory
based on the stack name under ~/tripleo-deploy instead of defaulting to
the home dir. This is a cleaner approach than just leaving all the files
in the home dir, especially given that tripleo deploy can deploy
multiple stacks, and if the same directory was used as the default,
there would be file collisions.

Closes-Bug: #1921975
Signed-off-by: James Slagle <jslagle@redhat.com>
Change-Id: Idded7faba1ff6c811b94503c559029aeeaca6a06
2021-05-06 21:17:26 -04:00

49 lines
1.8 KiB
Python

# Copyright 2018 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.
#
from oslo_config import cfg
class BaseConfig(object):
def sort_opts(self, opts):
"""Sort oslo config options by name
:param opts: list of olo cfg opts
:return list - sorted by name
"""
def sort_cfg(cfg):
return cfg.name
return sorted(opts, key=sort_cfg)
def get_base_opts(self):
_opts = [
# TODO(aschultz): rename undercloud_output_dir
cfg.StrOpt('output_dir',
help=(
'Directory to output state, processed heat '
'templates, ansible deployment files.'
'Defaults to ~/tripleo-deploy/<stack>')),
cfg.BoolOpt('cleanup',
default=True,
help=('Cleanup temporary files. Setting this to '
'False will leave the temporary files used '
'during deployment in place after the command '
'is run. This is useful for debugging the '
'generated files or if errors occur.'),
),
]
return self.sort_opts(_opts)