Implement the minimal changes to the local filesystem storage driver and feed them through the distributed storage driver. Create a digest package which contains digest_tools and checksums. Fix the tests to use the new v1 endpoint locations. Fix repository.delete_instance to properly filter the generated queries to avoid most subquery deletes, but still generate them when not explicitly filtered.
22 lines
701 B
Python
22 lines
701 B
Python
from data.model import config, DataModelException
|
|
|
|
from data.database import ImageStorage, Image, ImageStorageLocation, ImageStoragePlacement
|
|
|
|
|
|
class BlobDoesNotExist(DataModelException):
|
|
pass
|
|
|
|
|
|
def get_blob_by_digest(blob_digest):
|
|
try:
|
|
return ImageStorage.get(checksum=blob_digest)
|
|
except ImageStorage.DoesNotExist:
|
|
raise BlobDoesNotExist('Blob does not exist with digest: {0}'.format(blob_digest))
|
|
|
|
|
|
def store_blob_record(blob_digest, location_name):
|
|
storage = ImageStorage.create(checksum=blob_digest)
|
|
location = ImageStorageLocation.get(name=location_name)
|
|
ImageStoragePlacement.create(location=location, storage=storage)
|
|
storage.locations = {location_name}
|
|
return storage
|