コード例 #1
0
    def test_export_passwords(self):
        swift = mock.Mock()
        mock_passwords = {'passwords': {'a': 'A', 'b': 'B'}}
        sio = StringIO()
        sio.write(six.text_type(yaml.dump(mock_passwords)))
        sio.seek(0)
        swift.get_object.return_value = ("", sio)
        data = export.export_passwords(swift, 'overcloud')

        swift.get_object.assert_called_once_with('overcloud',
                                                 'plan-environment.yaml')

        self.assertEqual(mock_passwords['passwords'], data)
コード例 #2
0
    def test_export_passwords_excludes(self):
        swift = mock.Mock()
        mock_passwords = {
            'passwords': {
                'a': 'A',
                'b': 'B',
                'Cephkey': 'cephkey',
                'cephkey': 'cephkey',
                'CEPH': 'cephkey'
            }
        }
        sio = StringIO()
        sio.write(six.text_type(yaml.dump(mock_passwords)))
        sio.seek(0)
        swift.get_object.return_value = ("", sio)
        data = export.export_passwords(swift, 'overcloud')

        mock_passwords['passwords'].pop('Cephkey')
        mock_passwords['passwords'].pop('cephkey')
        mock_passwords['passwords'].pop('CEPH')

        self.assertEqual(mock_passwords['passwords'], data)
コード例 #3
0
    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)
コード例 #4
0
    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)