diff options
author | Morgan Richomme <morgan.richomme@orange.com> | 2016-08-26 06:48:26 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@172.30.200.206> | 2016-08-26 06:48:26 +0000 |
commit | 874eac1d00c9624d084b3c7b01075a7645c5b840 (patch) | |
tree | e5716aad90288dfaa9d39fc550571862381f6e87 /testcases/OpenStack | |
parent | 2b22d89b5a3dc212774d0a426e53d569f98173a7 (diff) | |
parent | 5f5af6b1d8d0af19db143e67f04f67a643af863c (diff) |
Merge "refactor create or get image process to eliminate reduplicate"
Diffstat (limited to 'testcases/OpenStack')
-rwxr-xr-x | testcases/OpenStack/rally/run_rally-cert.py | 26 | ||||
-rwxr-xr-x | testcases/OpenStack/tempest/run_tempest.py | 22 | ||||
-rw-r--r-- | testcases/OpenStack/vPing/vping_util.py | 23 |
3 files changed, 15 insertions, 56 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, diff --git a/testcases/OpenStack/tempest/run_tempest.py b/testcases/OpenStack/tempest/run_tempest.py index 64a5ed778..10b22c9f5 100755 --- a/testcases/OpenStack/tempest/run_tempest.py +++ b/testcases/OpenStack/tempest/run_tempest.py @@ -126,7 +126,6 @@ def get_info(file_result): def create_tempest_resources(): keystone_client = os_utils.get_keystone_client() neutron_client = os_utils.get_neutron_client() - glance_client = os_utils.get_glance_client() logger.debug("Creating tenant and user for Tempest suite") tenant_id = os_utils.create_tenant(keystone_client, @@ -159,22 +158,11 @@ def create_tempest_resources(): exit(-1) logger.debug("Creating image for Tempest suite") - # Check if the given image exists - image_id = os_utils.get_image_id(glance_client, GLANCE_IMAGE_NAME) - if image_id != '': - logger.info("Using existing image '%s'..." % GLANCE_IMAGE_NAME) - else: - logger.info("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 a Glance image...") - exit(-1) - logger.debug("Image '%s' with ID=%s created successfully." - % (GLANCE_IMAGE_NAME, image_id)) + _, image_id = os_utils.get_or_create_image(GLANCE_IMAGE_NAME, + GLANCE_IMAGE_PATH, + GLANCE_IMAGE_FORMAT) + if not image_id: + exit(-1) def configure_tempest(deployment_dir): diff --git a/testcases/OpenStack/vPing/vping_util.py b/testcases/OpenStack/vPing/vping_util.py index c16c5d659..3f4adae73 100644 --- a/testcases/OpenStack/vPing/vping_util.py +++ b/testcases/OpenStack/vPing/vping_util.py @@ -147,24 +147,11 @@ def create_security_group(): def create_image(): - EXIT_CODE = -1 - - # Check if the given image exists - image_id = os_utils.get_image_id(glance_client, GLANCE_IMAGE_NAME) - if image_id != '': - logger.info("Using existing image '%s'..." % GLANCE_IMAGE_NAME) - else: - logger.info("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 a Glance image...") - exit(EXIT_CODE) - logger.debug("Image '%s' with ID=%s created successfully." - % (GLANCE_IMAGE_NAME, image_id)) + _, image_id = os_utils.get_or_create_image(GLANCE_IMAGE_NAME, + GLANCE_IMAGE_PATH, + GLANCE_IMAGE_FORMAT) + if not image_id: + exit(-1) return image_id |