def register_plugin(self, plugin_instance):
        """Register a particular instance of a BaseStoragePlugin"""
        # FIXME: session ID not really used for anything, it's a vague
        # nod to the future remote-run plugins.
        session_id = plugin_instance.__class__.__name__

        storage_plugin_log.info("Registered plugin instance %s with id %s" % (plugin_instance, session_id))
        return session_id
    def get_or_create_root(cls, resource_class, resource_class_id, attrs):
        # Root resource do not have parents so they must be globally identified
        from chroma_core.lib.storage_plugin.api.identifiers import AutoId, ScopedId

        if isinstance(resource_class._meta.identifier, ScopedId):
            raise RuntimeError(
                "Cannot create root resource of class %s, it requires a scope"
                % resource_class)

        if isinstance(resource_class._meta.identifier, AutoId):
            import uuid

            attrs["chroma_auto_id"] = uuid.uuid4().__str__()
        id_str = json.dumps(resource_class.attrs_to_id_tuple(attrs, False))

        # NB assumes that none of the items in ID tuple are ResourceReferences: this
        # would raise an exception from json encoding.
        # FIXME: weird separate code path for creating resources (cf resourcemanager)
        try:
            # See if you're trying to create something which already exists
            existing_record = StorageResourceRecord.objects.get(
                resource_class=resource_class_id,
                storage_id_str=id_str,
                storage_id_scope=None)
            return existing_record, False
        except StorageResourceRecord.DoesNotExist:
            # Great, nothing in the way
            pass

        record = StorageResourceRecord(resource_class_id=resource_class_id,
                                       storage_id_str=id_str)
        record.save()

        log.info("StorageResourceRecord created %d" % (record.id))

        for name, value in attrs.items():
            attr_model_class = resource_class.attr_model_class(name)
            attr_model_class.objects.create(
                resource=record,
                key=name,
                value=attr_model_class.encode(value))

        return record, True