Clean '/tmp' after image upload from horizon
After image upload(successful or fails) from horizon, image cleaned up from the /tmp Closes-Bug: #1398766 Change-Id: I2c40e67234a8d0c8bdef9838b863ade9f5434083
This commit is contained in:
parent
60cfc4e234
commit
647c14e68b
@ -22,12 +22,15 @@ import collections
|
||||
import itertools
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
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
|
||||
@ -101,7 +104,21 @@ def image_list_detailed(request, marker=None, sort_dir='desc',
|
||||
|
||||
|
||||
def image_update(request, image_id, **kwargs):
|
||||
return glanceclient(request).images.update(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)
|
||||
finally:
|
||||
if image_data:
|
||||
try:
|
||||
os.remove(image_data.file.name)
|
||||
except Exception as e:
|
||||
msg = (('Failed to remove temporary image file '
|
||||
'%(file)s (%(e)s)') %
|
||||
dict(file=image_data.file.name, e=str(e)))
|
||||
LOG.warn(msg)
|
||||
return image
|
||||
|
||||
|
||||
def image_create(request, **kwargs):
|
||||
|
Loading…
x
Reference in New Issue
Block a user