summaryrefslogtreecommitdiffstats
path: root/testcases/OpenStack/rally
diff options
context:
space:
mode:
authorSerenaFeng <feng.xiaowei@zte.com.cn>2016-08-23 13:44:36 +0800
committerMorgan Richomme <morgan.richomme@orange.com>2016-08-26 06:48:33 +0000
commitf3da85065e34b3058cace165443f6f919f959a0b (patch)
treee5716aad90288dfaa9d39fc550571862381f6e87 /testcases/OpenStack/rally
parent224f176cee5544483f3a37bb59a3d9aae1791e44 (diff)
refactor create or get image process to eliminate reduplicate
Some places when create image is referred, they check if image exist, if exist use it directly, else create a new one. Abstract a method to integrate the process JIRA: FUNCTEST-432 Change-Id: I83d1112aa5cb0d3cdfab92fd49cd5f2c1cceff82 Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn> (cherry picked from commit 5f5af6b1d8d0af19db143e67f04f67a643af863c)
Diffstat (limited to 'testcases/OpenStack/rally')
-rwxr-xr-xtestcases/OpenStack/rally/run_rally-cert.py26
1 files changed, 5 insertions, 21 deletions
diff --git a/testcases/OpenStack/rally/run_rally-cert.py b/testcases/OpenStack/rally/run_rally-cert.py
index 92dbddff6..279bcde0e 100755
--- a/testcases/OpenStack/rally/run_rally-cert.py
+++ b/testcases/OpenStack/rally/run_rally-cert.py
@@ -376,7 +376,6 @@ def main():
nova_client = os_utils.get_nova_client()
neutron_client = os_utils.get_neutron_client()
- glance_client = os_utils.get_glance_client()
cinder_client = os_utils.get_cinder_client()
start_time = time.time()
@@ -402,26 +401,11 @@ def main():
else:
logger.debug("Using existing volume type(s)...")
- image_id = os_utils.get_image_id(glance_client, GLANCE_IMAGE_NAME)
- image_exists = False
-
- if image_id == '':
- logger.debug("Creating image '%s' from '%s'..." % (GLANCE_IMAGE_NAME,
- GLANCE_IMAGE_PATH))
- image_id = os_utils.create_glance_image(glance_client,
- GLANCE_IMAGE_NAME,
- GLANCE_IMAGE_PATH,
- GLANCE_IMAGE_FORMAT)
- if not image_id:
- logger.error("Failed to create the Glance image...")
- exit(-1)
- else:
- logger.debug("Image '%s' with ID '%s' created succesfully ."
- % (GLANCE_IMAGE_NAME, image_id))
- else:
- logger.debug("Using existing image '%s' with ID '%s'..."
- % (GLANCE_IMAGE_NAME, image_id))
- image_exists = True
+ image_exists, image_id = os_utils.get_or_create_image(GLANCE_IMAGE_NAME,
+ GLANCE_IMAGE_PATH,
+ GLANCE_IMAGE_FORMAT)
+ if not image_id:
+ exit(-1)
logger.debug("Creating network '%s'..." % PRIVATE_NET_NAME)
network_dict = os_utils.create_network_full(neutron_client,