Merge "Creating uuid -> id mapping for S3 Image Service"

This commit is contained in:
Jenkins 2011-10-31 18:47:56 +00:00 committed by Gerrit Code Review
commit 35a2df2b55
2 changed files with 57 additions and 1 deletions
nova/db
api.py
sqlalchemy

@ -1593,3 +1593,21 @@ def vsa_get_all(context):
def vsa_get_all_by_project(context, project_id):
"""Get all Virtual Storage Array records by project ID."""
return IMPL.vsa_get_all_by_project(context, project_id)
###################
def s3_image_get(context, image_id):
"""Find local s3 image represented by the provided id"""
return IMPL.s3_image_get(context, image_id)
def s3_image_get_by_uuid(context, image_uuid):
"""Find local s3 image represented by the provided uuid"""
return IMPL.s3_image_get_by_uuid(context, image_uuid)
def s3_image_create(context, image_uuid):
"""Create local s3 image represented by provided uuid"""
return IMPL.s3_image_create(context, image_uuid)

@ -4017,4 +4017,42 @@ def vsa_get_all_by_project(context, project_id):
all()
####################
####################
def s3_image_get(context, image_id):
"""Find local s3 image represented by the provided id"""
session = get_session()
res = session.query(models.S3Image)\
.filter_by(id=image_id)\
.first()
if not res:
raise exception.ImageNotFound(image_id=image_id)
return res
def s3_image_get_by_uuid(context, image_uuid):
"""Find local s3 image represented by the provided uuid"""
session = get_session()
res = session.query(models.S3Image)\
.filter_by(uuid=image_uuid)\
.first()
if not res:
raise exception.ImageNotFound(image_id=image_uuid)
return res
def s3_image_create(context, image_uuid):
"""Create local s3 image represented by provided uuid"""
try:
s3_image_ref = models.S3Image()
s3_image_ref.update({'uuid': image_uuid})
s3_image_ref.save()
except Exception, e:
raise exception.DBError(e)
return s3_image_ref