From 6daa237e66205707e5638ff46e894af81f9f219a Mon Sep 17 00:00:00 2001 From: "jose.lausuch" Date: Wed, 23 Dec 2015 12:14:41 +0100 Subject: Add 'check if file exists' when creating the glance image Change-Id: I2f61d130ac49ca0cc6bdde6b3da209ec37f24452 Signed-off-by: jose.lausuch --- testcases/functest_utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/testcases/functest_utils.py b/testcases/functest_utils.py index a0d91357d..875060835 100644 --- a/testcases/functest_utils.py +++ b/testcases/functest_utils.py @@ -10,6 +10,7 @@ import os +import os.path import urllib2 import subprocess import sys @@ -336,16 +337,20 @@ def get_image_id(glance_client, image_name): return id -def create_glance_image(glance_client, image_name, file_path, is_public=True): +def create_glance_image(glance_client, image_name, file_path, public=True): + if not os.path.isfile(file_path): + print "Error: file "+file_path+" does not exist." + return False try: with open(file_path) as fimage: image = glance_client.images.create(name=image_name, - is_public=is_public, + is_public=public, disk_format="qcow2", container_format="bare", data=fimage) return image.id except: + print "Error:", sys.exc_info()[0] return False def delete_glance_image(nova_client, image_id): -- cgit 1.2.3-korg