Rename 'undercloud-' to '<stack_name>-'
Instead of hardcoding 'undercloud' for the artifacts and password files, let's name them: - Directory: <stack_name>-install - Archive: <stack_name>-install-%s.tar.bzip2 - tripleo-<stack_name>-passwords.yaml Depends-On: Iab62ca6bb209524e923ad44a3d8d6079fc976cef Change-Id: I1e65235017b0b223c53e1c8b48ad2ac573e4ccca
This commit is contained in:
parent
3d1a850302
commit
baeb0032ef
|
@ -513,7 +513,7 @@ class TestDeployUndercloud(TestPluginV1):
|
|||
{'name': 'Foo', 'tags': ['primary']}
|
||||
]
|
||||
|
||||
def set_tht(templates):
|
||||
def set_tht(templates, stack_name):
|
||||
self.cmd.tht_render = "tht_from"
|
||||
|
||||
mock_populate.side_effect = set_tht
|
||||
|
|
|
@ -219,13 +219,13 @@ class Deploy(command.Command):
|
|||
'first defined role')
|
||||
return roles_data[0]['name']
|
||||
|
||||
def _get_tar_filename(self):
|
||||
def _get_tar_filename(self, stack_name='undercloud'):
|
||||
"""Return tarball name for the install artifacts"""
|
||||
return '%s/undercloud-install-%s.tar.bzip2' % \
|
||||
(self.output_dir,
|
||||
return '%s/%s-install-%s.tar.bzip2' % \
|
||||
(self.output_dir, stack_name,
|
||||
datetime.utcnow().strftime('%Y%m%d%H%M%S'))
|
||||
|
||||
def _create_install_artifact(self, user):
|
||||
def _create_install_artifact(self, user, stack_name='undercloud'):
|
||||
"""Create a tarball of the temporary folders used"""
|
||||
self.log.debug(_("Preserving deployment artifacts"))
|
||||
|
||||
|
@ -238,7 +238,8 @@ class Deploy(command.Command):
|
|||
|
||||
# tar up working data and put in
|
||||
# output_dir/undercloud-install-TS.tar.bzip2
|
||||
tar_filename = self._get_tar_filename()
|
||||
# if the stack name is "undercloud".
|
||||
tar_filename = self._get_tar_filename(stack_name)
|
||||
try:
|
||||
tf = tarfile.open(tar_filename, 'w:bz2')
|
||||
tf.add(self.tht_render, recursive=True, filter=remove_output_dir)
|
||||
|
@ -258,7 +259,7 @@ class Deploy(command.Command):
|
|||
if not os.path.exists(constants.STANDALONE_EPHEMERAL_STACK_VSTATE):
|
||||
os.mkdir(constants.STANDALONE_EPHEMERAL_STACK_VSTATE)
|
||||
|
||||
def _create_working_dirs(self):
|
||||
def _create_working_dirs(self, stack_name='undercloud'):
|
||||
"""Creates temporary working directories"""
|
||||
if self.output_dir and not os.path.exists(self.output_dir):
|
||||
os.mkdir(self.output_dir)
|
||||
|
@ -272,9 +273,10 @@ class Deploy(command.Command):
|
|||
shutil.rmtree(self.tht_render, ignore_errors=True)
|
||||
if not self.tmp_ansible_dir:
|
||||
self.tmp_ansible_dir = tempfile.mkdtemp(
|
||||
prefix='undercloud-ansible-', dir=self.output_dir)
|
||||
prefix=stack_name + '-ansible-', dir=self.output_dir)
|
||||
|
||||
def _populate_templates_dir(self, source_templates_dir):
|
||||
def _populate_templates_dir(self, source_templates_dir,
|
||||
stack_name='undercloud'):
|
||||
"""Creates template dir with templates
|
||||
|
||||
* Copy --templates content into a working dir
|
||||
|
@ -283,7 +285,7 @@ class Deploy(command.Command):
|
|||
:param source_templates_dir: string to a directory containing our
|
||||
source templates
|
||||
"""
|
||||
self._create_working_dirs()
|
||||
self._create_working_dirs(stack_name)
|
||||
if not os.path.exists(source_templates_dir):
|
||||
raise exceptions.NotFound("%s templates directory does not exist "
|
||||
"or permission denied" %
|
||||
|
@ -333,10 +335,11 @@ class Deploy(command.Command):
|
|||
constants.PUPPET_BASE)
|
||||
|
||||
def _update_passwords_env(self, output_dir, user, upgrade=None,
|
||||
passwords=None):
|
||||
pw_file = os.path.join(output_dir, 'tripleo-undercloud-passwords.yaml')
|
||||
passwords=None, stack_name='undercloud'):
|
||||
pw_file = os.path.join(output_dir,
|
||||
'tripleo-' + stack_name + '-passwords.yaml')
|
||||
undercloud_pw_file = os.path.join(output_dir,
|
||||
'undercloud-passwords.conf')
|
||||
stack_name + '-passwords.conf')
|
||||
|
||||
# Generated passwords take the lowest precedence, allowing
|
||||
# custom overrides
|
||||
|
@ -669,9 +672,10 @@ class Deploy(command.Command):
|
|||
# this will allow the user to overwrite passwords with custom envs
|
||||
# or pick instack legacy passwords as is, if upgrading from instack
|
||||
pw_file = self._update_passwords_env(
|
||||
self.output_dir,
|
||||
parsed_args.deployment_user,
|
||||
parsed_args.upgrade,
|
||||
output_dir=self.output_dir,
|
||||
user=parsed_args.deployment_user,
|
||||
upgrade=parsed_args.upgrade,
|
||||
stack_name=parsed_args.stack.lower(),
|
||||
)
|
||||
environments.append(pw_file)
|
||||
|
||||
|
@ -716,7 +720,8 @@ class Deploy(command.Command):
|
|||
if parsed_args.hieradata_override:
|
||||
environments.append(self._process_hieradata_overrides(
|
||||
parsed_args.hieradata_override,
|
||||
parsed_args.standalone_role))
|
||||
parsed_args.standalone_role,
|
||||
parsed_args.stack.lower()))
|
||||
|
||||
# Create a persistent drop-in file to indicate the stack
|
||||
# virtual state changes
|
||||
|
@ -777,7 +782,8 @@ class Deploy(command.Command):
|
|||
self.log.info('Removing unused services, updating roles')
|
||||
# This will clean up the directory and set it up again
|
||||
self.tht_render = None
|
||||
self._populate_templates_dir(parsed_args.templates)
|
||||
self._populate_templates_dir(parsed_args.templates,
|
||||
parsed_args.stack.lower())
|
||||
roles_file_path = os.path.join(
|
||||
self.tht_render, 'roles-data-override.yaml')
|
||||
with open(roles_file_path, "w") as f:
|
||||
|
@ -826,7 +832,7 @@ class Deploy(command.Command):
|
|||
tripleo_role_name='Standalone',
|
||||
python_interpreter=sys.executable):
|
||||
stack_config = config.Config(client)
|
||||
self._create_working_dirs()
|
||||
self._create_working_dirs(stack_name.lower())
|
||||
|
||||
self.log.warning(_('** Downloading {0} ansible.. **').format(
|
||||
stack_name))
|
||||
|
@ -886,7 +892,7 @@ class Deploy(command.Command):
|
|||
globalcfg['oslo_messaging_notify_node_names'] = [name]
|
||||
outputs['GlobalConfigExtraMapData'] = globalcfg
|
||||
|
||||
self._create_working_dirs()
|
||||
self._create_working_dirs(stack_name.lower())
|
||||
output = {'parameter_defaults': outputs}
|
||||
with open(endpointmap_file, 'w') as f:
|
||||
yaml.safe_dump(output, f, default_flow_style=False)
|
||||
|
@ -1110,7 +1116,8 @@ class Deploy(command.Command):
|
|||
return parser
|
||||
|
||||
def _process_hieradata_overrides(self, override_file=None,
|
||||
tripleo_role_name='Standalone'):
|
||||
tripleo_role_name='Standalone',
|
||||
stack_name='undercloud'):
|
||||
"""Count in hiera data overrides including legacy formats
|
||||
|
||||
Return a file name that points to processed hiera data overrides file
|
||||
|
@ -1138,7 +1145,7 @@ class Deploy(command.Command):
|
|||
target)
|
||||
self.log.error(msg)
|
||||
raise exceptions.DeploymentError(msg)
|
||||
self._create_working_dirs()
|
||||
self._create_working_dirs(stack_name)
|
||||
|
||||
# NOTE(bogdando): In t-h-t, hiera data should come in wrapped as
|
||||
# {parameter_defaults: {UndercloudExtraConfig: ... }}
|
||||
|
@ -1205,7 +1212,7 @@ class Deploy(command.Command):
|
|||
|
||||
# prepare working spaces
|
||||
self.output_dir = os.path.abspath(parsed_args.output_dir)
|
||||
self._create_working_dirs()
|
||||
self._create_working_dirs(parsed_args.stack.lower())
|
||||
# The state that needs to be persisted between serial deployments
|
||||
# and cannot be contained in ephemeral heat stacks or working dirs
|
||||
self._create_persistent_dirs()
|
||||
|
@ -1214,7 +1221,8 @@ class Deploy(command.Command):
|
|||
self._configure_puppet()
|
||||
|
||||
# copy the templates dir in place
|
||||
self._populate_templates_dir(parsed_args.templates)
|
||||
self._populate_templates_dir(parsed_args.templates,
|
||||
parsed_args.stack.lower())
|
||||
|
||||
# Set default plan if not specified by user
|
||||
self._set_default_plan()
|
||||
|
@ -1312,7 +1320,8 @@ class Deploy(command.Command):
|
|||
if not parsed_args.keep_running:
|
||||
self._kill_heat(parsed_args)
|
||||
tar_filename = \
|
||||
self._create_install_artifact(parsed_args.deployment_user)
|
||||
self._create_install_artifact(parsed_args.deployment_user,
|
||||
parsed_args.stack.lower())
|
||||
if self.ansible_dir:
|
||||
self._dump_ansible_errors(
|
||||
os.path.join(self.ansible_dir,
|
||||
|
|
Loading…
Reference in New Issue