def handle_cleanup(self, project, project_id=None, resource_type=None,
                       operation_type=None):
        """Cleans up Barbican resources needed for Keystone project delete.

        :param project: Barbican project entity which is retrieved by project
        id available in Keystone notification.
        :param project_id: project identifier as present in Keystone
        notification.
        :param resource_type: type of resource updated as part of Keystone
        notification e.g. Keystone project, domain, user etc.
        :param operation_type: type of operation (created, updated, deleted
        etc.) performed on Keystone resource.
        """
        if project is None:
            LOG.info(u._LI('No action is needed as there are no Barbican '
                           'resources present for Keystone '
                           'project_id=%s'), project_id)
            return

        # barbican entities use projects table 'id' field as foreign key.
        # Delete apis are using that id to lookup related entities and not
        # keystone project id which requires additional project table join.
        project_id = project.id

        rep.delete_all_project_resources(project_id)

        # reached here means there is no error so log the successful
        # cleanup log entry.
        LOG.info(u._LI('Successfully completed Barbican resources cleanup for '
                       'Keystone project_id=%s'), project_id)
Exemple #2
0
    def handle_cleanup(self, project, project_id=None, resource_type=None,
                       operation_type=None):
        """Cleans up Barbican resources needed for Keystone project delete.

        :param project: Barbican project entity which is retrieved by project
        id available in Keystone notification.
        :param project_id: project identifier as present in Keystone
        notification.
        :param resource_type: type of resource updated as part of Keystone
        notification e.g. Keystone project, domain, user etc.
        :param operation_type: type of operation (created, updated, deleted
        etc.) performed on Keystone resource.
        """
        if project is None:
            LOG.info(u._LI('No action is needed as there are no Barbican '
                           'resources present for Keystone '
                           'project_id=%s'), project_id)
            return

        # barbican entities use projects table 'id' field as foreign key.
        # Delete apis are using that id to lookup related entities and not
        # keystone project id which requires additional project table join.
        project_id = project.id

        rep.delete_all_project_resources(project_id)

        # reached here means there is no error so log the successful
        # cleanup log entry.
        LOG.info(u._LI('Successfully completed Barbican resources cleanup for '
                       'Keystone project_id=%s'), project_id)