Set DeployIndentifier early in tripleoclient-parameters.yaml

We can set the heat parameters in the client itslef and there
would be no need to update plan environment and can get rid of
the ansible tasks for those.

Same applies for RootStackName.

Also, removes multiple redundant calls to _update_parameters()

Change-Id: I54762eb6881113c67744207f53fd92cf003e0559
This commit is contained in:
Rabi Mishra
2020-12-14 13:07:32 +05:30
committed by ramishra
parent 44b94ee9bf
commit e11dcaea5d
2 changed files with 29 additions and 12 deletions

View File

@@ -246,6 +246,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
'NeutronPublicInterface': 'nic1', 'NeutronPublicInterface': 'nic1',
'NtpServer': '', 'NtpServer': '',
'SnmpdReadonlyUserPassword': 'PASSWORD', 'SnmpdReadonlyUserPassword': 'PASSWORD',
'DeployIdentifier': 12345678,
'RootStackName': 'overcloud',
'StackAction': 'UPDATE', 'StackAction': 'UPDATE',
'UndercloudHostsEntries': [ 'UndercloudHostsEntries': [
'192.168.0.1 uc.ctlplane.localhost uc.ctlplane'], '192.168.0.1 uc.ctlplane.localhost uc.ctlplane'],
@@ -346,6 +348,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
parameters_env = { parameters_env = {
'parameter_defaults': { 'parameter_defaults': {
'StackAction': 'CREATE', 'StackAction': 'CREATE',
'DeployIdentifier': 12345678,
'RootStackName': 'overcloud',
'UndercloudHostsEntries': 'UndercloudHostsEntries':
['192.168.0.1 uc.ctlplane.localhost uc.ctlplane'], ['192.168.0.1 uc.ctlplane.localhost uc.ctlplane'],
'CtlplaneNetworkAttributes': {}}} 'CtlplaneNetworkAttributes': {}}}
@@ -481,6 +485,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
'NtpServer': '', 'NtpServer': '',
'SnmpdReadonlyUserPassword': 'PASSWORD', 'SnmpdReadonlyUserPassword': 'PASSWORD',
'StackAction': 'CREATE', 'StackAction': 'CREATE',
'DeployIdentifier': 12345678,
'RootStackName': 'overcloud',
'UndercloudHostsEntries': [ 'UndercloudHostsEntries': [
'192.168.0.1 uc.ctlplane.localhost uc.ctlplane' '192.168.0.1 uc.ctlplane.localhost uc.ctlplane'
], ],
@@ -1238,6 +1244,8 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
'NeutronTunnelTypes': 'gre', 'NeutronTunnelTypes': 'gre',
'SnmpdReadonlyUserPassword': 'PASSWORD', 'SnmpdReadonlyUserPassword': 'PASSWORD',
'StackAction': 'CREATE', 'StackAction': 'CREATE',
'DeployIdentifier': 12345678,
'RootStackName': 'overcloud',
'NtpServer': 'ntp', 'NtpServer': 'ntp',
'UndercloudHostsEntries': [ 'UndercloudHostsEntries': [
'192.168.0.1 uc.ctlplane.localhost uc.ctlplane' '192.168.0.1 uc.ctlplane.localhost uc.ctlplane'
@@ -1552,11 +1560,15 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
# assuming heat deploy consumed a 3m out of total 451m timeout # assuming heat deploy consumed a 3m out of total 451m timeout
with mock.patch('time.time', side_effect=[0, 1585820346, with mock.patch('time.time', side_effect=[0, 1585820346,
0, 0, 1585820526]): 0, 12345678, 0,
1585820526]):
self.cmd.take_action(parsed_args) self.cmd.take_action(parsed_args)
self.assertIn( self.assertIn(
[mock.call(mock.ANY, mock.ANY, 'overcloud', mock.ANY, [mock.call(mock.ANY, mock.ANY, 'overcloud', mock.ANY,
{'StackAction': 'UPDATE', 'UndercloudHostsEntries': {'StackAction': 'UPDATE',
'DeployIdentifier': 12345678,
'RootStackName': 'overcloud',
'UndercloudHostsEntries':
['192.168.0.1 uc.ctlplane.localhost uc.ctlplane'], ['192.168.0.1 uc.ctlplane.localhost uc.ctlplane'],
'CtlplaneNetworkAttributes': {}}, {}, 451, mock.ANY, 'CtlplaneNetworkAttributes': {}}, {}, 451, mock.ANY,
{}, False, False, False, None, deployment_options={})], {}, False, False, False, None, deployment_options={})],

View File

@@ -73,13 +73,7 @@ class DeployOvercloud(command.Command):
'Assuming --deployed-server') 'Assuming --deployed-server')
parsed_args.deployed_server = True parsed_args.deployed_server = True
def _update_parameters(self, args, stack): def _update_args_from_answers_file(self, args):
parameters = {}
stack_is_new = stack is None
parameters['StackAction'] = 'CREATE' if stack_is_new else 'UPDATE'
# Update parameters from answers file: # Update parameters from answers file:
if args.answers_file is not None: if args.answers_file is not None:
with open(args.answers_file, 'r') as answers_file: with open(args.answers_file, 'r') as answers_file:
@@ -92,6 +86,19 @@ class DeployOvercloud(command.Command):
answers['environments'].extend(args.environment_files) answers['environments'].extend(args.environment_files)
args.environment_files = answers['environments'] args.environment_files = answers['environments']
def _update_parameters(self, args, stack):
parameters = {}
stack_is_new = stack is None
parameters['RootStackName'] = args.stack
if not args.skip_deploy_identifier:
parameters['DeployIdentifier'] = int(time.time())
else:
parameters['DeployIdentifier'] = ''
parameters['StackAction'] = 'CREATE' if stack_is_new else 'UPDATE'
param_args = ( param_args = (
('NtpServer', 'ntp_server'), ('NtpServer', 'ntp_server'),
) )
@@ -1062,10 +1069,8 @@ class DeployOvercloud(command.Command):
utils.check_deprecated_service_is_enabled( utils.check_deprecated_service_is_enabled(
parsed_args.environment_files) parsed_args.environment_files)
self._update_args_from_answers_file(parsed_args)
stack = utils.get_stack(self.orchestration_client, parsed_args.stack) stack = utils.get_stack(self.orchestration_client, parsed_args.stack)
self._update_parameters(parsed_args, stack)
stack_create = stack is None stack_create = stack is None
if stack_create: if stack_create:
self.log.info("No stack found, will be doing a stack create") self.log.info("No stack found, will be doing a stack create")