summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2015-12-23 12:14:41 +0100
committerjose.lausuch <jose.lausuch@ericsson.com>2015-12-23 12:14:41 +0100
commit6daa237e66205707e5638ff46e894af81f9f219a (patch)
tree4e7200138845320669db55d3fd15e84a8758e943
parentb7aaca61bf27d62e5974009fa68dba0564d3154e (diff)
Add 'check if file exists' when creating the glance image
Change-Id: I2f61d130ac49ca0cc6bdde6b3da209ec37f24452 Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
-rw-r--r--testcases/functest_utils.py9
1 files 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):