Don't download configs twice for --setup-only

Also fixes to download the contents to the consistent
working directory by default.

Change-Id: I33944b3d21a4448a5d89f6d5f1bf539f0b7c9cd1
This commit is contained in:
ramishra 2021-05-26 08:59:30 +05:30
parent 8800f06c94
commit 4243df7de1
3 changed files with 32 additions and 67 deletions

View File

@ -1079,7 +1079,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
'region': 'region1'} 'region': 'region1'}
self.cmd.take_action(parsed_args) self.cmd.take_action(parsed_args)
self.assertTrue(fixture.mock_get_hosts_and_enable_ssh_admin.called) self.assertTrue(fixture.mock_get_hosts_and_enable_ssh_admin.called)
self.assertTrue(fixture.mock_config_download.called)
self.assertTrue(fixture.mock_set_deployment_status.called) self.assertTrue(fixture.mock_set_deployment_status.called)
self.assertEqual( self.assertEqual(
'DEPLOY_SUCCESS', 'DEPLOY_SUCCESS',
@ -1291,7 +1290,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
deployment_options={}, deployment_options={},
deployment_timeout=448, # 451 - 3, total time left deployment_timeout=448, # 451 - 3, total time left
in_flight_validations=False, limit_hosts=None, in_flight_validations=False, limit_hosts=None,
setup_only=False, skip_tags=None, tags=None, timeout=42, skip_tags=None, tags=None, timeout=42,
verbosity=3, forks=None)], verbosity=3, forks=None)],
fixture.mock_config_download.mock_calls) fixture.mock_config_download.mock_calls)
fixture.mock_config_download.assert_called() fixture.mock_config_download.assert_called()

View File

@ -851,10 +851,7 @@ class DeployOvercloud(command.Command):
parser.add_argument( parser.add_argument(
'--config-dir', '--config-dir',
dest='config_dir', dest='config_dir',
default=os.path.join( default=None,
constants.CLOUD_HOME_DIR,
'tripleo-config'
),
help=_('The directory where the configuration files will be ' help=_('The directory where the configuration files will be '
'pushed'), 'pushed'),
) )
@ -1100,7 +1097,7 @@ class DeployOvercloud(command.Command):
config_download_dir = parsed_args.output_dir or \ config_download_dir = parsed_args.output_dir or \
os.path.join(self.working_dir, "config-download") os.path.join(self.working_dir, "config-download")
if parsed_args.config_download or parsed_args.setup_only: if parsed_args.config_download:
self.log.info("Deploying overcloud configuration") self.log.info("Deploying overcloud configuration")
deployment.set_deployment_status( deployment.set_deployment_status(
stack.stack_name, stack.stack_name,
@ -1108,8 +1105,7 @@ class DeployOvercloud(command.Command):
working_dir=self.working_dir working_dir=self.working_dir
) )
if not parsed_args.config_download_only and \ if not parsed_args.config_download_only:
not parsed_args.setup_only:
deployment.get_hosts_and_enable_ssh_admin( deployment.get_hosts_and_enable_ssh_admin(
stack, stack,
parsed_args.overcloud_ssh_network, parsed_args.overcloud_ssh_network,
@ -1129,38 +1125,36 @@ class DeployOvercloud(command.Command):
raise exceptions.DeploymentError( raise exceptions.DeploymentError(
'Deployment timed out after %sm' % used) 'Deployment timed out after %sm' % used)
deployment_options = {} if not parsed_args.setup_only:
if parsed_args.deployment_python_interpreter: deployment_options = {}
deployment_options['ansible_python_interpreter'] = \ if parsed_args.deployment_python_interpreter:
parsed_args.deployment_python_interpreter deployment_options['ansible_python_interpreter'] = \
parsed_args.deployment_python_interpreter
deployment.make_config_download_dir(config_download_dir, deployment.make_config_download_dir(config_download_dir,
parsed_args.stack) parsed_args.stack)
deployment.config_download( deployment.config_download(
self.log, self.log,
self.clients, self.clients,
stack, stack,
parsed_args.overcloud_ssh_network, parsed_args.overcloud_ssh_network,
config_download_dir, config_download_dir,
parsed_args.override_ansible_cfg, parsed_args.override_ansible_cfg,
timeout=parsed_args.overcloud_ssh_port_timeout, timeout=parsed_args.overcloud_ssh_port_timeout,
verbosity=utils.playbook_verbosity(self=self), verbosity=utils.playbook_verbosity(self=self),
deployment_options=deployment_options, deployment_options=deployment_options,
in_flight_validations=parsed_args.inflight, in_flight_validations=parsed_args.inflight,
deployment_timeout=timeout, deployment_timeout=timeout,
tags=parsed_args.tags, tags=parsed_args.tags,
skip_tags=parsed_args.skip_tags, skip_tags=parsed_args.skip_tags,
limit_hosts=utils.playbook_limit_parse( limit_hosts=utils.playbook_limit_parse(
limit_nodes=parsed_args.limit limit_nodes=parsed_args.limit
), ),
forks=parsed_args.ansible_forks, forks=parsed_args.ansible_forks)
setup_only=parsed_args.setup_only else:
)
if parsed_args.setup_only:
# Download config # Download config
config_dir = os.path.abspath(parsed_args.config_dir) config_dir = parsed_args.config_dir or config_download_dir
config_type = parsed_args.config_type config_type = parsed_args.config_type
preserve_config_dir = parsed_args.preserve_config_dir preserve_config_dir = parsed_args.preserve_config_dir
extra_vars = { extra_vars = {
@ -1180,18 +1174,6 @@ class DeployOvercloud(command.Command):
verbosity=utils.playbook_verbosity(self=self), verbosity=utils.playbook_verbosity(self=self),
extra_vars=extra_vars extra_vars=extra_vars
) )
# Run admin authorize
deployment.get_hosts_and_enable_ssh_admin(
stack,
parsed_args.overcloud_ssh_network,
parsed_args.overcloud_ssh_user,
self.get_key_pair(parsed_args),
parsed_args.overcloud_ssh_port_timeout,
verbosity=utils.playbook_verbosity(self=self),
heat_type=parsed_args.heat_type
)
deployment.set_deployment_status( deployment.set_deployment_status(
stack.stack_name, stack.stack_name,
status=deploy_status, status=deploy_status,

View File

@ -249,8 +249,7 @@ def config_download(log, clients, stack, ssh_network='ctlplane',
ansible_playbook_name='deploy_steps_playbook.yaml', ansible_playbook_name='deploy_steps_playbook.yaml',
limit_hosts=None, extra_vars=None, inventory_path=None, limit_hosts=None, extra_vars=None, inventory_path=None,
ssh_user='tripleo-admin', tags=None, skip_tags=None, ssh_user='tripleo-admin', tags=None, skip_tags=None,
deployment_timeout=None, forks=None, setup_only=False, deployment_timeout=None, forks=None, working_dir=None):
working_dir=None):
"""Run config download. """Run config download.
:param log: Logging object :param log: Logging object
@ -309,10 +308,6 @@ def config_download(log, clients, stack, ssh_network='ctlplane',
:param deployment_timeout: Deployment timeout in minutes. :param deployment_timeout: Deployment timeout in minutes.
:type deployment_timeout: Integer :type deployment_timeout: Integer
:param setup_only: Only generates the config-download directory
without executing the actual playbooks.
:type setup_only: Boolean
:param working_dir: Consistent working directory used for generated :param working_dir: Consistent working directory used for generated
ansible files. ansible files.
:type working_dir: String :type working_dir: String
@ -409,17 +404,6 @@ def config_download(log, clients, stack, ssh_network='ctlplane',
} }
) )
# If we only want to generate config-download directory, we can quit here.
if setup_only:
_log_and_print(
message='Overcloud configuration generated for stack: {}'.format(
stack.stack_name
),
logger=log,
print_msg=(verbosity == 0)
)
return
_log_and_print( _log_and_print(
message='Executing deployment playbook for stack: {}'.format( message='Executing deployment playbook for stack: {}'.format(
stack.stack_name stack.stack_name