Merge "Use a consistent working directory for tripleo deploy"
This commit is contained in:
commit
792101230c
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- The "openstack tripleo deploy" and "openstack undercloud install" commands
|
||||||
|
now save their generated artifacts from the deployment under a single
|
||||||
|
consistent directory, which by default is located at
|
||||||
|
~/tripleo-deploy/<stack>. For the undercloud, this location is
|
||||||
|
~/tripleo-deploy/undercloud. The directory can be overridden with the
|
||||||
|
--output-dir option.
|
@ -14,7 +14,6 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from tripleoclient import constants
|
|
||||||
|
|
||||||
|
|
||||||
class BaseConfig(object):
|
class BaseConfig(object):
|
||||||
@ -33,11 +32,10 @@ class BaseConfig(object):
|
|||||||
_opts = [
|
_opts = [
|
||||||
# TODO(aschultz): rename undercloud_output_dir
|
# TODO(aschultz): rename undercloud_output_dir
|
||||||
cfg.StrOpt('output_dir',
|
cfg.StrOpt('output_dir',
|
||||||
default=constants.UNDERCLOUD_OUTPUT_DIR,
|
|
||||||
help=(
|
help=(
|
||||||
'Directory to output state, processed heat '
|
'Directory to output state, processed heat '
|
||||||
'templates, ansible deployment files.'),
|
'templates, ansible deployment files.'
|
||||||
),
|
'Defaults to ~/tripleo-deploy/<stack>')),
|
||||||
cfg.BoolOpt('cleanup',
|
cfg.BoolOpt('cleanup',
|
||||||
default=True,
|
default=True,
|
||||||
help=('Cleanup temporary files. Setting this to '
|
help=('Cleanup temporary files. Setting this to '
|
||||||
|
@ -98,9 +98,8 @@ class MinionConfig(StandaloneConfig):
|
|||||||
help=_(
|
help=_(
|
||||||
'The name of the file to look for the passwords '
|
'The name of the file to look for the passwords '
|
||||||
'used to connect to the Undercloud. We assume '
|
'used to connect to the Undercloud. We assume '
|
||||||
'this file is in the folder where the command '
|
'this file is in output_dir if a fully qualified '
|
||||||
'is executed if a fully qualified path is not '
|
'path is not provided.')
|
||||||
'provided.')
|
|
||||||
),
|
),
|
||||||
cfg.StrOpt('minion_undercloud_output_file',
|
cfg.StrOpt('minion_undercloud_output_file',
|
||||||
default='tripleo-undercloud-outputs.yaml',
|
default='tripleo-undercloud-outputs.yaml',
|
||||||
|
@ -54,6 +54,11 @@ class UtilsOvercloudFixture(fixtures.Fixture):
|
|||||||
fixtures.MockPatch(
|
fixtures.MockPatch(
|
||||||
'tripleoclient.utils.update_deployment_status')
|
'tripleoclient.utils.update_deployment_status')
|
||||||
).mock
|
).mock
|
||||||
|
self.mock_get_default_working_dir = self.useFixture(fixtures.MockPatch(
|
||||||
|
'tripleoclient.utils.get_default_working_dir')
|
||||||
|
).mock
|
||||||
|
self.mock_get_default_working_dir.return_value = \
|
||||||
|
self.useFixture(fixtures.TempDir()).path
|
||||||
|
|
||||||
|
|
||||||
class UtilsFixture(fixtures.Fixture):
|
class UtilsFixture(fixtures.Fixture):
|
||||||
|
@ -1663,14 +1663,10 @@ def build_stack_data(clients, stack_name, template,
|
|||||||
return stack_data
|
return stack_data
|
||||||
|
|
||||||
|
|
||||||
def archive_deploy_artifacts(log, stack_name, working_dir,
|
def archive_deploy_artifacts(log, stack_name, working_dir, ansible_dir=None):
|
||||||
ansible_dir=None, output_dir=None):
|
|
||||||
"""Create a tarball of the temporary folders used"""
|
"""Create a tarball of the temporary folders used"""
|
||||||
log.debug(_("Preserving deployment artifacts"))
|
log.debug(_("Preserving deployment artifacts"))
|
||||||
|
|
||||||
if not output_dir:
|
|
||||||
output_dir = working_dir
|
|
||||||
|
|
||||||
def get_tar_filename():
|
def get_tar_filename():
|
||||||
return os.path.join(
|
return os.path.join(
|
||||||
working_dir, '%s-install-%s.tar.bzip2' %
|
working_dir, '%s-install-%s.tar.bzip2' %
|
||||||
@ -1681,7 +1677,7 @@ def archive_deploy_artifacts(log, stack_name, working_dir,
|
|||||||
"""Tar filter to remove output dir from path"""
|
"""Tar filter to remove output dir from path"""
|
||||||
if info.name.endswith('.bzip2'):
|
if info.name.endswith('.bzip2'):
|
||||||
return None
|
return None
|
||||||
leading_path = output_dir[1:] + '/'
|
leading_path = working_dir[1:] + '/'
|
||||||
info.name = info.name.replace(leading_path, '')
|
info.name = info.name.replace(leading_path, '')
|
||||||
return info
|
return info
|
||||||
|
|
||||||
|
@ -146,7 +146,13 @@ def prepare_minion_deploy(upgrade=False, no_validations=False,
|
|||||||
# picked up later.
|
# picked up later.
|
||||||
# NOTE(aschultz): We copy this into the tht root that we save because
|
# NOTE(aschultz): We copy this into the tht root that we save because
|
||||||
# we move any user provided environment files into this root later.
|
# we move any user provided environment files into this root later.
|
||||||
tempdir = os.path.join(os.path.abspath(CONF['output_dir']),
|
if not CONF.get('output_dir'):
|
||||||
|
output_dir = os.path.join(constants.MINION_OUTPUT_DIR,
|
||||||
|
'tripleo-deploy',
|
||||||
|
'minion')
|
||||||
|
else:
|
||||||
|
output_dir = CONF['output_dir']
|
||||||
|
tempdir = os.path.join(os.path.abspath(output_dir),
|
||||||
'tripleo-config-generated-env-files')
|
'tripleo-config-generated-env-files')
|
||||||
utils.makedirs(tempdir)
|
utils.makedirs(tempdir)
|
||||||
|
|
||||||
@ -219,8 +225,10 @@ def prepare_minion_deploy(upgrade=False, no_validations=False,
|
|||||||
# copy undercloud password file (the configuration is minion_password_file
|
# copy undercloud password file (the configuration is minion_password_file
|
||||||
# to the place that triple deploy looks for it
|
# to the place that triple deploy looks for it
|
||||||
# tripleo-<stack name>-passwords.yaml)
|
# tripleo-<stack name>-passwords.yaml)
|
||||||
_process_undercloud_passwords(CONF['minion_password_file'],
|
_process_undercloud_passwords(
|
||||||
'tripleo-minion-passwords.yaml')
|
CONF['minion_password_file'],
|
||||||
|
os.path.join(output_dir, 'tripleo-minion-passwords.yaml'))
|
||||||
|
|
||||||
if upgrade:
|
if upgrade:
|
||||||
# TODO(aschultz): validate minion upgrade, should be the same as the
|
# TODO(aschultz): validate minion upgrade, should be the same as the
|
||||||
# undercloud one.
|
# undercloud one.
|
||||||
@ -269,8 +277,8 @@ def prepare_minion_deploy(upgrade=False, no_validations=False,
|
|||||||
# TODO(cjeanner) drop that once using oslo.privsep
|
# TODO(cjeanner) drop that once using oslo.privsep
|
||||||
deploy_args += ['--deployment-user', u]
|
deploy_args += ['--deployment-user', u]
|
||||||
|
|
||||||
deploy_args += ['--output-dir=%s' % CONF['output_dir']]
|
deploy_args += ['--output-dir=%s' % output_dir]
|
||||||
utils.makedirs(CONF['output_dir'])
|
utils.makedirs(output_dir)
|
||||||
|
|
||||||
# TODO(aschultz): move this to a central class
|
# TODO(aschultz): move this to a central class
|
||||||
if CONF.get('net_config_override', None):
|
if CONF.get('net_config_override', None):
|
||||||
|
@ -915,8 +915,8 @@ class Deploy(command.Command):
|
|||||||
parser.add_argument('--output-dir',
|
parser.add_argument('--output-dir',
|
||||||
dest='output_dir',
|
dest='output_dir',
|
||||||
help=_("Directory to output state, processed heat "
|
help=_("Directory to output state, processed heat "
|
||||||
"templates, ansible deployment files."),
|
"templates, ansible deployment files.\n"
|
||||||
default=constants.UNDERCLOUD_OUTPUT_DIR)
|
"Defaults to ~/tripleo-deploy/<stack>"))
|
||||||
parser.add_argument('--output-only',
|
parser.add_argument('--output-only',
|
||||||
dest='output_only',
|
dest='output_only',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
@ -1219,7 +1219,13 @@ class Deploy(command.Command):
|
|||||||
self._run_preflight_checks(parsed_args)
|
self._run_preflight_checks(parsed_args)
|
||||||
|
|
||||||
# prepare working spaces
|
# prepare working spaces
|
||||||
self.output_dir = os.path.abspath(parsed_args.output_dir)
|
if not parsed_args.output_dir:
|
||||||
|
output_dir = os.path.join(constants.UNDERCLOUD_OUTPUT_DIR,
|
||||||
|
'tripleo-deploy',
|
||||||
|
parsed_args.stack)
|
||||||
|
else:
|
||||||
|
output_dir = parsed_args.output_dir
|
||||||
|
self.output_dir = os.path.abspath(output_dir)
|
||||||
self._create_working_dirs(parsed_args.stack.lower())
|
self._create_working_dirs(parsed_args.stack.lower())
|
||||||
# The state that needs to be persisted between serial deployments
|
# The state that needs to be persisted between serial deployments
|
||||||
# and cannot be contained in ephemeral heat stacks or working dirs
|
# and cannot be contained in ephemeral heat stacks or working dirs
|
||||||
@ -1342,8 +1348,6 @@ class Deploy(command.Command):
|
|||||||
utils.archive_deploy_artifacts(
|
utils.archive_deploy_artifacts(
|
||||||
self.log,
|
self.log,
|
||||||
parsed_args.stack.lower(),
|
parsed_args.stack.lower(),
|
||||||
self.tht_render,
|
|
||||||
self.tmp_ansible_dir,
|
|
||||||
self.output_dir)
|
self.output_dir)
|
||||||
|
|
||||||
if self.ansible_dir:
|
if self.ansible_dir:
|
||||||
|
@ -453,11 +453,17 @@ def prepare_undercloud_deploy(upgrade=False, no_validations=True,
|
|||||||
utils.configure_logging(LOG, verbose_level, CONF['undercloud_log_file'])
|
utils.configure_logging(LOG, verbose_level, CONF['undercloud_log_file'])
|
||||||
_load_subnets_config_groups()
|
_load_subnets_config_groups()
|
||||||
|
|
||||||
|
if not CONF.get('output_dir'):
|
||||||
|
output_dir = os.path.join(constants.UNDERCLOUD_OUTPUT_DIR,
|
||||||
|
'tripleo-deploy',
|
||||||
|
'undercloud')
|
||||||
|
else:
|
||||||
|
output_dir = CONF['output_dir']
|
||||||
# NOTE(bogdando): the generated env files are stored another path then
|
# NOTE(bogdando): the generated env files are stored another path then
|
||||||
# picked up later.
|
# picked up later.
|
||||||
# NOTE(aschultz): We copy this into the tht root that we save because
|
# NOTE(aschultz): We copy this into the tht root that we save because
|
||||||
# we move any user provided environment files into this root later.
|
# we move any user provided environment files into this root later.
|
||||||
tempdir = os.path.join(os.path.abspath(CONF['output_dir']),
|
tempdir = os.path.join(os.path.abspath(output_dir),
|
||||||
'tripleo-config-generated-env-files')
|
'tripleo-config-generated-env-files')
|
||||||
utils.makedirs(tempdir)
|
utils.makedirs(tempdir)
|
||||||
|
|
||||||
@ -756,8 +762,8 @@ def prepare_undercloud_deploy(upgrade=False, no_validations=True,
|
|||||||
# TODO(cjeanner) drop that once using oslo.privsep
|
# TODO(cjeanner) drop that once using oslo.privsep
|
||||||
deploy_args += ['--deployment-user', u]
|
deploy_args += ['--deployment-user', u]
|
||||||
|
|
||||||
deploy_args += ['--output-dir=%s' % CONF['output_dir']]
|
deploy_args += ['--output-dir=%s' % output_dir]
|
||||||
utils.makedirs(CONF['output_dir'])
|
utils.makedirs(output_dir)
|
||||||
|
|
||||||
if CONF.get('cleanup'):
|
if CONF.get('cleanup'):
|
||||||
deploy_args.append('--cleanup')
|
deploy_args.append('--cleanup')
|
||||||
|
Loading…
Reference in New Issue
Block a user