def test_export_stack_cd_dir(self, mock_get_stack): heat = mock.Mock() mock_get_stack.return_value = self.mock_stack with mock.patch('six.moves.builtins.open', self.mock_open): export.export_stack(heat, "overcloud", config_download_dir='/foo') self.mock_open.assert_called_once_with( '/foo/overcloud/group_vars/overcloud.json', 'r')
def test_export_stack(self, mock_get_stack): heat = mock.Mock() mock_get_stack.return_value = self.mock_stack with mock.patch('six.moves.builtins.open', self.mock_open): data = export.export_stack(heat, "overcloud") expected = \ {'AllNodesExtraMapData': {u'an_key': u'an_value'}, 'EndpointMapOverride': {'em_key': 'em_value'}, 'ExtraHostFileEntries': 'hosts entry', 'GlobalConfigExtraMapData': {'gc_key': 'gc_value'}} self.assertEqual(expected, data) self.mock_open.assert_called_once_with( '/var/lib/mistral/overcloud/group_vars/overcloud.json', 'r')
def test_export_stack_should_filter(self, mock_get_stack): heat = mock.Mock() mock_get_stack.return_value = self.mock_stack self.mock_open = mock.mock_open( read_data='{"an_key":"an_value","ovn_dbs_vip":"vip"}') with mock.patch('six.moves.builtins.open', self.mock_open): data = export.export_stack(heat, "overcloud", should_filter=True) expected = \ {'AllNodesExtraMapData': {u'ovn_dbs_vip': u'vip'}, 'EndpointMapOverride': {'em_key': 'em_value'}, 'ExtraHostFileEntries': 'hosts entry', 'GlobalConfigExtraMapData': {'gc_key': 'gc_value'}} self.assertEqual(expected, data) self.mock_open.assert_called_once_with( os.path.join( os.environ.get('HOME'), 'config-download/overcloud/group_vars/overcloud.json'), 'r')
def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) stack = parsed_args.stack output_file = parsed_args.output_file or \ '%s-export.yaml' % stack self.log.info('Running at %s with parameters %s', self.now, parsed_args) if os.path.exists(output_file) and not parsed_args.force_overwrite: raise Exception( "File '%s' already exists, not exporting." % output_file) if not parsed_args.config_download_dir: config_download_dir = os.path.join(os.environ.get('HOME'), 'config-download', parsed_args.stack) else: config_download_dir = parsed_args.config_download_dir # prepare clients to access the environment clients = self.app.client_manager swift_client = clients.tripleoclient.object_store data = export.export_passwords(swift_client, stack, not parsed_args.no_password_excludes) data.update(export.export_stack( clients.orchestration, stack, False, config_download_dir)) data = dict(parameter_defaults=data) # write the exported data with open(output_file, 'w') as f: yaml.safe_dump(data, f, default_flow_style=False) print("Stack information exported to %s." % output_file)
def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) control_plane_stack = parsed_args.control_plane_stack cell_stack = parsed_args.cell_stack cell_name = parsed_args.name output_file = parsed_args.output_file or \ '%s-cell-input.yaml' % cell_name self.log.info('Running at %s with parameters %s', self.now, parsed_args) if os.path.exists(output_file) and not parsed_args.force_overwrite: raise exceptions.CellExportError( "File '%s' already exists, not exporting." % output_file) # prepare clients to access the environment clients = self.app.client_manager swift_client = clients.tripleoclient.object_store data = export.export_passwords(swift_client, control_plane_stack) stack_to_export = control_plane_stack should_filter = True if cell_stack: stack_to_export = cell_stack should_filter = False config_download_dir = os.path.join(MISTRAL_VAR, stack_to_export) data.update( export.export_stack(clients.orchestration, stack_to_export, should_filter, config_download_dir)) data = dict(parameter_defaults=data) # write the exported data with open(output_file, 'w') as f: yaml.safe_dump(data, f, default_flow_style=False) print("Cell input information exported to %s." % output_file) msg = """ \n\n Next steps: ===========\n * Create roles file for cell stack, e.g.: openstack overcloud roles generate --roles-path \\ /usr/share/openstack-tripleo-heat-templates/roles \\ -o cell_roles_data.yaml Compute CellController * Create new flavor used to tag the cell controller * Tag cell controller nodes into the new flavor * Create cell parameter file as explained in bellow doc link * Deploy the cell and make sure to add the following information to the deploy command: - additional environment files used for overcloud stack - --stack <cellname> - cell role file created - the exported cell input information file {output_file} - other specific parameter files for the cell\n For more details check https://docs.openstack.org/ project-deploy-guide/tripleo-docs/latest/features/deploy_cellv2.html """.format(output_file=output_file) print(msg)
def test_export_stack_stack_name(self, mock_get_stack): heat = mock.Mock() mock_get_stack.return_value = self.mock_stack with mock.patch('six.moves.builtins.open', self.mock_open): export.export_stack(heat, "control") mock_get_stack.assert_called_once_with(heat, 'control')