From 8241aef9291ba554f891da2d994c4b0795ef8002 Mon Sep 17 00:00:00 2001 From: Sergey Nikitin Date: Tue, 22 Apr 2014 11:53:44 +0400 Subject: [PATCH] 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 --- glance/api/v2/image_data.py | 1 + 1 file changed, 1 insertion(+) diff --git a/glance/api/v2/image_data.py b/glance/api/v2/image_data.py index 97b03bbd35..956cde2504 100644 --- a/glance/api/v2/image_data.py +++ b/glance/api/v2/image_data.py @@ -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'