Merge "Make standalone role name configurable"

This commit is contained in:
Zuul 2018-05-24 13:18:06 +00:00 committed by Gerrit Code Review
commit 355d504fbd
5 changed files with 37 additions and 17 deletions

View File

@ -397,7 +397,8 @@ class TestDeployUndercloud(TestPluginV1):
mock_importInv.return_value = mock_inventory
self.cmd.output_dir = fake_output_dir
self.cmd._download_ansible_playbooks(mock_launch_heat,
'undercloud')
'undercloud',
'Undercloud')
self.assertEqual(mock_flush.call_count, 2)
mock_inventory.write_static_inventory.assert_called_once_with(
fake_output_dir + '/inventory.yaml', extra_vars)
@ -479,6 +480,7 @@ class TestDeployUndercloud(TestPluginV1):
'--templates', '/tmp/thtroot',
'--stack', 'undercloud',
'--output-dir', '/my',
'--standalone-role', 'Undercloud',
'-e', '/tmp/thtroot/puppet/foo.yaml',
'-e', '/tmp/thtroot//docker/bar.yaml',
'-e', '/tmp/thtroot42/notouch.yaml',
@ -495,7 +497,7 @@ class TestDeployUndercloud(TestPluginV1):
mock_tht.assert_called_once_with(self.cmd, fake_orchestration,
parsed_args)
mock_download.assert_called_with(self.cmd, fake_orchestration,
'undercloud')
'undercloud', 'Undercloud')
mock_launchansible.assert_called_once()
mock_tarball.assert_called_once()
mock_cleanupdirs.assert_called_once()

View File

@ -77,6 +77,7 @@ class TestUndercloudInstall(TestPluginV1):
mock_os.assert_called_with('/foo/tripleo-config-generated-env-files')
mock_subprocess.assert_called_with(
['sudo', 'openstack', 'tripleo', 'deploy', '--standalone',
'--standalone-role', 'Undercloud',
'--local-domain=localdomain',
'--local-ip=192.168.24.1/24',
'--templates=/usr/share/openstack-tripleo-heat-templates/',
@ -233,6 +234,7 @@ class TestUndercloudInstall(TestPluginV1):
mock_subprocess.assert_called_with(
['sudo', 'openstack', 'tripleo', 'deploy', '--standalone',
'--standalone-role', 'Undercloud',
'--local-domain=localdomain',
'--local-ip=192.168.24.1/24',
'--templates=/usr/share/openstack-tripleo-heat-templates/',
@ -292,6 +294,7 @@ class TestUndercloudInstall(TestPluginV1):
mock_subprocess.assert_called_with(
['sudo', 'openstack', 'tripleo', 'deploy', '--standalone',
'--standalone-role', 'Undercloud',
'--local-domain=localdomain',
'--local-ip=192.168.24.1/24',
'--templates=/usr/share/openstack-tripleo-heat-templates/',
@ -347,6 +350,7 @@ class TestUndercloudInstall(TestPluginV1):
mock_subprocess.assert_called_with(
['sudo', 'openstack', 'tripleo', 'deploy', '--standalone',
'--standalone-role', 'Undercloud',
'--local-domain=localdomain',
'--local-ip=192.168.24.1/24',
'--templates=/usr/share/openstack-tripleo-heat-templates/',
@ -439,6 +443,7 @@ class TestUndercloudUpgrade(TestPluginV1):
mock_subprocess.assert_called_with(
['sudo', 'openstack', 'tripleo', 'deploy', '--standalone',
'--standalone-role', 'Undercloud',
'--local-domain=localdomain',
'--local-ip=192.168.24.1/24',
'--templates=/usr/share/openstack-tripleo-heat-templates/',
@ -495,6 +500,7 @@ class TestUndercloudUpgrade(TestPluginV1):
mock_subprocess.assert_called_with(
['sudo', 'openstack', 'tripleo', 'deploy', '--standalone',
'--standalone-role', 'Undercloud',
'--local-domain=localdomain',
'--local-ip=192.168.24.1/24',
'--templates=/usr/share/openstack-tripleo-heat-templates/',
@ -555,6 +561,7 @@ class TestUndercloudUpgrade(TestPluginV1):
mock_subprocess.assert_called_with(
['sudo', 'openstack', 'tripleo', 'deploy', '--standalone',
'--standalone-role', 'Undercloud',
'--local-domain=localdomain',
'--local-ip=192.168.24.1/24',
'--templates=/usr/share/openstack-tripleo-heat-templates/',

View File

@ -501,7 +501,8 @@ class Deploy(command.Command):
if parsed_args.hieradata_override:
environments.append(self._process_hieradata_overrides(
parsed_args.hieradata_override))
parsed_args.hieradata_override,
parsed_args.standalone_role))
return environments
@ -562,15 +563,17 @@ class Deploy(command.Command):
return "%s/%s" % (stack_name, stack_id)
def _download_ansible_playbooks(self, client, stack_name):
def _download_ansible_playbooks(self, client, stack_name,
tripleo_role_name='Standalone'):
stack_config = config.Config(client)
self._create_working_dirs()
self.log.warning(_('** Downloading undercloud ansible.. **'))
self.log.warning(_('** Downloading {0} ansible.. **').format(
stack_name))
# python output buffering is making this seem to take forever..
sys.stdout.flush()
stack_config.write_config(stack_config.fetch_config('undercloud'),
'undercloud',
stack_config.write_config(stack_config.fetch_config(stack_name),
stack_name,
self.tmp_ansible_dir)
inventory = TripleoInventory(
@ -579,11 +582,11 @@ class Deploy(command.Command):
ansible_ssh_user='root')
inv_path = os.path.join(self.tmp_ansible_dir, 'inventory.yaml')
extra_vars = {'Undercloud': {'ansible_connection': 'local'}}
extra_vars = {tripleo_role_name: {'ansible_connection': 'local'}}
inventory.write_static_inventory(inv_path, extra_vars)
self.log.info(_('** Downloaded undercloud ansible to %s **') %
self.tmp_ansible_dir)
self.log.info(_('** Downloaded {0} ansible to {1} **').format(
stack_name, self.tmp_ansible_dir))
sys.stdout.flush()
return self.tmp_ansible_dir
@ -638,6 +641,10 @@ class Deploy(command.Command):
help=_("Do not execute the Ansible playbooks. By"
" default the playbooks are saved to the"
" output-dir and then executed.")),
parser.add_argument('--standalone-role', default='Standalone',
help=_("The role to use for standalone "
"configuration when populating the "
"deployment actions."))
parser.add_argument('-t', '--timeout', metavar='<TIMEOUT>',
type=int, default=30,
help=_('Deployment timeout in minutes.'))
@ -722,7 +729,7 @@ class Deploy(command.Command):
help=_('Path to hieradata override file. When it points to a heat '
'env file, it is passed in t-h-t via --environment-file. '
'When the file contains legacy instack data, '
'it is wrapped with UndercloudExtraConfig and also '
'it is wrapped with <role>ExtraConfig and also '
'passed in for t-h-t as a temp file created in '
'--output-dir. Note, instack hiera data may be '
'not t-h-t compatible and will highly likely require a '
@ -730,7 +737,8 @@ class Deploy(command.Command):
)
return parser
def _process_hieradata_overrides(self, override_file=None):
def _process_hieradata_overrides(self, override_file=None,
tripleo_role_name='Standalone'):
"""Count in hiera data overrides including legacy formats
Return a file name that points to processed hiera data overrides file
@ -755,8 +763,8 @@ class Deploy(command.Command):
# NOTE(bogdando): In t-h-t, hiera data should come in wrapped as
# {parameter_defaults: {UndercloudExtraConfig: ... }}
if ('UndercloudExtraConfig' not in hiera_data.get('parameter_defaults',
{})):
extra_config_var = '%sExtraConfig' % tripleo_role_name
if (extra_config_var not in hiera_data.get('parameter_defaults', {})):
hiera_override_file = os.path.join(
self.tht_render, 'tripleo-hieradata-override.yaml')
self.log.info('Converting hiera overrides for t-h-t from '
@ -765,7 +773,7 @@ class Deploy(command.Command):
with open(hiera_override_file, 'w') as override:
yaml.safe_dump(
{'parameter_defaults': {
'UndercloudExtraConfig': hiera_data}},
extra_config_var: hiera_data}},
override,
default_flow_style=False)
target = hiera_override_file
@ -824,7 +832,8 @@ class Deploy(command.Command):
# download the ansible playbooks and execute them.
ansible_dir = \
self._download_ansible_playbooks(orchestration_client,
parsed_args.stack)
parsed_args.stack,
parsed_args.standalone_role)
# Kill heat, we're done with it now.
self._kill_heat(parsed_args)
if not parsed_args.output_only:

View File

@ -570,7 +570,8 @@ def prepare_undercloud_deploy(upgrade=False, no_validations=False,
LOG_FILE = os.path.join(os.getcwd() + '/install-undercloud.log')
deploy_args.append('--log-file=' + LOG_FILE)
cmd = ["sudo", "openstack", "tripleo", "deploy", "--standalone"]
cmd = ["sudo", "openstack", "tripleo", "deploy", "--standalone",
"--standalone-role", "Undercloud"]
cmd += deploy_args[:]
return cmd

View File

@ -31,4 +31,5 @@ class DeployUndercloud(Deploy):
# add in --standalone if we were invoked via undercloud deploy
parsed_args.standalone = True
parsed_args.standalone_role = 'Undercloud'
super(DeployUndercloud, self).take_action(parsed_args)