Browse Source

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

changes/83/793383/9
Zuul 5 months ago
committed by Gerrit Code Review
parent
commit
c4261c4420
  1. 3
      tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py
  2. 80
      tripleoclient/v1/overcloud_deploy.py
  3. 18
      tripleoclient/workflows/deployment.py

3
tripleoclient/tests/v1/overcloud_deploy/test_overcloud_deploy.py

@ -1079,7 +1079,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
'region': 'region1'}
self.cmd.take_action(parsed_args)
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.assertEqual(
'DEPLOY_SUCCESS',
@ -1291,7 +1290,7 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
deployment_options={},
deployment_timeout=448, # 451 - 3, total time left
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)],
fixture.mock_config_download.mock_calls)
fixture.mock_config_download.assert_called()

80
tripleoclient/v1/overcloud_deploy.py

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

18
tripleoclient/workflows/deployment.py

@ -249,8 +249,7 @@ def config_download(log, clients, stack, ssh_network='ctlplane',
ansible_playbook_name='deploy_steps_playbook.yaml',
limit_hosts=None, extra_vars=None, inventory_path=None,
ssh_user='tripleo-admin', tags=None, skip_tags=None,
deployment_timeout=None, forks=None, setup_only=False,
working_dir=None):
deployment_timeout=None, forks=None, working_dir=None):
"""Run config download.
:param log: Logging object
@ -309,10 +308,6 @@ def config_download(log, clients, stack, ssh_network='ctlplane',
:param deployment_timeout: Deployment timeout in minutes.
: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
ansible files.
: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(
message='Executing deployment playbook for stack: {}'.format(
stack.stack_name

Loading…
Cancel
Save