Assign local variable in api.v2.image_data

If local variable 'image' will be not initialized we get UnboundLocalError
while handle following exceptions:
exception.StorageFull
exception.StorageQuotaFull
exception.ImageSizeLimitExceeded
exception.StorageWriteDenied
webob.exc.HTTPError
ValueError

This is because not initialized variable 'image' used as argument of
method _restore. That is why we should initialize it.

Closes-Bug: #1310952

Change-Id: I3bf73ca272aad479416067495006476934a01dd9
This commit is contained in:
Sergey Nikitin 2014-04-22 11:53:44 +04:00
parent f7effe4a4f
commit 8241aef929

View File

@ -61,6 +61,7 @@ class ImageDataController(object):
@utils.mutating
def upload(self, req, image_id, data, size):
image_repo = self.gateway.get_repo(req.context)
image = None
try:
image = image_repo.get(image_id)
image.status = 'saving'