summaryrefslogtreecommitdiffstats
path: root/snaps/openstack/utils/glance_utils.py
diff options
context:
space:
mode:
authorspisarski <s.pisarski@cablelabs.com>2017-05-25 08:46:40 -0600
committerspisarski <s.pisarski@cablelabs.com>2017-05-25 08:46:40 -0600
commit5718894fcfb3e44dd08435cf71d2f1094425bed5 (patch)
tree49a3d582cb01bff697a648ee901372312d56bdb4 /snaps/openstack/utils/glance_utils.py
parent74386c6efb02cc352b0b090b7150813960ca1c95 (diff)
Updated installation documents and fixed problems found during investigation.
The code changes are primarily required when the runtime environment is Windows. JIRA: SNAPS-75 Change-Id: Ia2134861dd96e1d2c4b597f42fb348929e787a51 Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/openstack/utils/glance_utils.py')
-rw-r--r--snaps/openstack/utils/glance_utils.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/snaps/openstack/utils/glance_utils.py b/snaps/openstack/utils/glance_utils.py
index 722cf4c..f4b4466 100644
--- a/snaps/openstack/utils/glance_utils.py
+++ b/snaps/openstack/utils/glance_utils.py
@@ -140,11 +140,18 @@ def __create_image_v2(glance, image_settings):
:raise Exception if using a file and it cannot be found
"""
cleanup_temp_file = False
+ image_file = None
if image_settings.image_file:
image_filename = image_settings.image_file
elif image_settings.url:
- image_file = file_utils.download(image_settings.url, '/tmp', str(uuid.uuid4()))
- image_filename = image_file.name
+ file_name = str(uuid.uuid4())
+ try:
+ image_file = file_utils.download(image_settings.url, './tmp', file_name)
+ image_filename = image_file.name
+ except:
+ os.remove('./tmp/' + file_name)
+ raise
+
cleanup_temp_file = True
else:
raise Exception('Filename or URL of image not configured')
@@ -171,6 +178,8 @@ def __create_image_v2(glance, image_settings):
delete_image(glance, created_image)
raise
finally:
+ if image_file:
+ image_file.close()
if cleanup_temp_file:
os.remove(image_filename)