Merge "Update cell export for ephemeral heat"

This commit is contained in:
Zuul 2022-07-13 20:57:33 +00:00 committed by Gerrit Code Review
commit 80612ac58b
2 changed files with 28 additions and 16 deletions

@ -15,8 +15,8 @@ from unittest import mock
from osc_lib.tests import utils from osc_lib.tests import utils
from tripleoclient.v1 import overcloud_cell from tripleoclient.v1 import overcloud_cell
from tripleoclient import constants
from tripleoclient.exceptions import CellExportError from tripleoclient.exceptions import CellExportError
from tripleoclient import utils as oooutils
class TestExportCell(utils.TestCommand): class TestExportCell(utils.TestCommand):
@ -50,13 +50,16 @@ class TestExportCell(utils.TestCommand):
self.cmd.take_action(parsed_args) self.cmd.take_action(parsed_args)
mock_path_exists.assert_any_call('overcloud-cell-export.yaml') mock_path_exists.assert_any_call('overcloud-cell-export.yaml')
mock_export_passwords.assert_called_once_with( mock_export_passwords.assert_called_once_with(
self.app.client_manager.orchestration, oooutils.get_default_working_dir('overcloud'),
'overcloud') 'overcloud')
mock_export_stack.assert_called_once_with( mock_export_stack.assert_called_once_with(
self.app.client_manager.orchestration, oooutils.get_default_working_dir('overcloud'),
'overcloud', 'overcloud',
True, True,
os.path.join(constants.DEFAULT_WORK_DIR, 'overcloud')) os.path.join(
oooutils.get_default_working_dir('overcloud'),
'config-download',
'overcloud'))
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()
@ -89,10 +92,10 @@ 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(
self.app.client_manager.orchestration, oooutils.get_default_working_dir('overcloud'),
'overcloud') 'overcloud')
mock_export_stack.assert_called_once_with( mock_export_stack.assert_called_once_with(
self.app.client_manager.orchestration, oooutils.get_default_working_dir('fizz'),
'fizz', 'fizz',
False, False,
os.path.join('buzz', 'fizz')) os.path.join('buzz', 'fizz'))

@ -19,9 +19,9 @@ from osc_lib.i18n import _
from osc_lib import utils from osc_lib import utils
from tripleoclient import command from tripleoclient import command
from tripleoclient import constants
from tripleoclient import exceptions from tripleoclient import exceptions
from tripleoclient import export from tripleoclient import export
from tripleoclient import utils as oooutils
class ExportCell(command.Command): class ExportCell(command.Command):
@ -48,11 +48,16 @@ class ExportCell(command.Command):
parser.add_argument('--output-file', '-o', metavar='<output file>', parser.add_argument('--output-file', '-o', metavar='<output file>',
help=_('Name of the output file for the cell data ' help=_('Name of the output file for the cell data '
'export. It will default to "<name>.yaml"')) 'export. It will default to "<name>.yaml"'))
parser.add_argument('--working-dir', action='store',
help=_('The working directory for the '
'deployment where all input, output, and '
'generated files are stored. Defaults to '
'"$HOME/overcloud-deploy/<stack>"'))
parser.add_argument('--config-download-dir', parser.add_argument('--config-download-dir',
action='store', action='store',
help=_('Directory to search for config-download ' help=_('Directory to search for config-download '
'export data. Defaults to ' 'export data. Defaults to $HOME/'
'$HOME/config-download')) 'overcloud-deploy/<stack>/config-download'))
parser.add_argument('--force-overwrite', '-f', action='store_true', parser.add_argument('--force-overwrite', '-f', action='store_true',
default=False, default=False,
help=_('Overwrite output file if it exists.')) help=_('Overwrite output file if it exists.'))
@ -77,11 +82,9 @@ 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)
# prepare clients to access the environment data = export.export_passwords(
clients = self.app.client_manager oooutils.get_default_working_dir(control_plane_stack),
heat = clients.orchestration control_plane_stack)
data = export.export_passwords(heat, control_plane_stack)
stack_to_export = control_plane_stack stack_to_export = control_plane_stack
should_filter = True should_filter = True
@ -89,15 +92,21 @@ class ExportCell(command.Command):
stack_to_export = cell_stack stack_to_export = cell_stack
should_filter = False should_filter = False
if not parsed_args.working_dir:
working_dir = oooutils.get_default_working_dir(stack_to_export)
else:
working_dir = parsed_args.working_dir
if not parsed_args.config_download_dir: if not parsed_args.config_download_dir:
download_dir = constants.DEFAULT_WORK_DIR download_dir = os.path.join(working_dir, 'config-download')
else: else:
download_dir = parsed_args.config_download_dir download_dir = parsed_args.config_download_dir
config_download_dir = os.path.join(download_dir, stack_to_export) config_download_dir = os.path.join(download_dir, stack_to_export)
data.update(export.export_stack( data.update(export.export_stack(
heat, stack_to_export, should_filter, oooutils.get_default_working_dir(stack_to_export),
stack_to_export, should_filter,
config_download_dir)) config_download_dir))
data = dict(parameter_defaults=data) data = dict(parameter_defaults=data)