Handle errors during glance image updates correctly
Before an UnboundLocalError would occur in case an error would happen during image updates, because of incorrect referencing of a variable. Moreover the error was muted by exceptions.handle with ignore=True, and could result in an incorrect success message. This change removes references to unused image variable and allows exceptions to be handled by the function, that calls image_update. Change-Id: I35ea98a146690565582dd9beea62941f97d32474 Closes-Bug: #1464991
This commit is contained in:
parent
5bde65705a
commit
7eb4e3595c
@ -34,7 +34,6 @@ from django.core.files.uploadedfile import TemporaryUploadedFile
|
||||
import glanceclient as glance_client
|
||||
from six.moves import _thread as thread
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon.utils import functions as utils
|
||||
from horizon.utils.memoized import memoized # noqa
|
||||
from openstack_dashboard.api import base
|
||||
@ -111,9 +110,7 @@ def image_list_detailed(request, marker=None, sort_dir='desc',
|
||||
def image_update(request, image_id, **kwargs):
|
||||
image_data = kwargs.get('data', None)
|
||||
try:
|
||||
image = glanceclient(request).images.update(image_id, **kwargs)
|
||||
except Exception:
|
||||
exceptions.handle(request, ignore=True)
|
||||
return glanceclient(request).images.update(image_id, **kwargs)
|
||||
finally:
|
||||
if image_data:
|
||||
try:
|
||||
@ -126,7 +123,6 @@ def image_update(request, image_id, **kwargs):
|
||||
'%(file)s (%(e)s)') %
|
||||
dict(file=filename, e=str(e)))
|
||||
LOG.warn(msg)
|
||||
return image
|
||||
|
||||
|
||||
def image_create(request, **kwargs):
|
||||
|
Loading…
Reference in New Issue
Block a user