From: jose.lausuch Date: Wed, 23 Dec 2015 11:14:41 +0000 (+0100) Subject: Add 'check if file exists' when creating the glance image X-Git-Tag: 0.2~1858 X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=commitdiff_plain;h=6daa237e66205707e5638ff46e894af81f9f219a;p=functest-xtesting.git Add 'check if file exists' when creating the glance image Change-Id: I2f61d130ac49ca0cc6bdde6b3da209ec37f24452 Signed-off-by: jose.lausuch --- diff --git a/testcases/functest_utils.py b/testcases/functest_utils.py index a0d91357..87506083 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):