Fix overcloud cell export paths

This was silently failing with the warning:
    File /home/stack/overcloud-deploy/overcloud/config-download/overcloud/overcloud/group_vars/overcloud.json was not found during export
    No data returned to export AllNodesExtraMapData from.

Since the stack name was appended to config_download_dir twice.

Also the working_dir, if given, was ignored when exporting passwords
and the default config_download_dir was based on the working_dir instead of
the documented default.

Change-Id: I77442878a6cc0fb7fb2bae71b888678099466300
This commit is contained in:
Oliver Walsh 2022-10-24 23:10:24 +01:00
parent 12e788906c
commit bcafdf7114
2 changed files with 14 additions and 14 deletions

View File

@ -57,9 +57,10 @@ class TestExportCell(utils.TestCommand):
'overcloud', 'overcloud',
True, True,
os.path.join( os.path.join(
oooutils.get_default_working_dir('overcloud'), os.environ.get('HOME'),
'config-download', 'overcloud-deploy',
'overcloud')) 'overcloud',
'config-download'))
mock_print.assert_called() mock_print.assert_called()
mock_open.assert_called_once_with('overcloud-cell-export.yaml', 'w') mock_open.assert_called_once_with('overcloud-cell-export.yaml', 'w')
mock_yaml_dump.assert_called_once() mock_yaml_dump.assert_called_once()
@ -92,13 +93,13 @@ class TestExportCell(utils.TestCommand):
self.cmd.take_action(parsed_args) self.cmd.take_action(parsed_args)
mock_path_exists.assert_any_call('fizz-cell-export.yaml') mock_path_exists.assert_any_call('fizz-cell-export.yaml')
mock_export_passwords.assert_called_once_with( mock_export_passwords.assert_called_once_with(
oooutils.get_default_working_dir('overcloud'), oooutils.get_default_working_dir('fizz'),
'overcloud') 'fizz')
mock_export_stack.assert_called_once_with( mock_export_stack.assert_called_once_with(
oooutils.get_default_working_dir('fizz'), oooutils.get_default_working_dir('fizz'),
'fizz', 'fizz',
False, False,
os.path.join('buzz', 'fizz')) 'buzz')
mock_print.assert_called() mock_print.assert_called()
mock_open.assert_called_once_with('fizz-cell-export.yaml', 'w') mock_open.assert_called_once_with('fizz-cell-export.yaml', 'w')
mock_yaml_dump.assert_called_once() mock_yaml_dump.assert_called_once()

View File

@ -82,10 +82,6 @@ class ExportCell(command.Command):
raise exceptions.CellExportError( raise exceptions.CellExportError(
"File '%s' already exists, not exporting." % output_file) "File '%s' already exists, not exporting." % output_file)
data = export.export_passwords(
oooutils.get_default_working_dir(control_plane_stack),
control_plane_stack)
stack_to_export = control_plane_stack stack_to_export = control_plane_stack
should_filter = True should_filter = True
if cell_stack: if cell_stack:
@ -98,14 +94,17 @@ class ExportCell(command.Command):
working_dir = parsed_args.working_dir working_dir = parsed_args.working_dir
if not parsed_args.config_download_dir: if not parsed_args.config_download_dir:
download_dir = os.path.join(working_dir, 'config-download') config_download_dir = os.path.join(os.environ.get('HOME'),
"overcloud-deploy",
stack_to_export,
'config-download')
else: else:
download_dir = parsed_args.config_download_dir config_download_dir = parsed_args.config_download_dir
config_download_dir = os.path.join(download_dir, stack_to_export) data = export.export_passwords(working_dir, stack_to_export)
data.update(export.export_stack( data.update(export.export_stack(
oooutils.get_default_working_dir(stack_to_export), working_dir,
stack_to_export, should_filter, stack_to_export, should_filter,
config_download_dir)) config_download_dir))
data = dict(parameter_defaults=data) data = dict(parameter_defaults=data)