aboutsummaryrefslogtreecommitdiffstats
path: root/testcases/VIM/OpenStack
diff options
context:
space:
mode:
authorJose Lausuch <jose.lausuch@ericsson.com>2015-12-29 17:42:28 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2015-12-29 17:42:28 +0000
commite250cde1fc43246c3464e0efd35fc5fb1fece561 (patch)
tree501250fd903c700db511fd28572ff81fb86ade88 /testcases/VIM/OpenStack
parentb7b28eba3b00a273be829fb29ed7a5e369139621 (diff)
parent679a2e1a15097991914ec57455ad22548c35b5b4 (diff)
Merge "Refactor run_rally-cert.py"
Diffstat (limited to 'testcases/VIM/OpenStack')
-rwxr-xr-xtestcases/VIM/OpenStack/CI/libraries/run_rally-cert.py46
1 files changed, 17 insertions, 29 deletions
diff --git a/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py b/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py
index c6e5505d7..18f91b878 100755
--- a/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py
+++ b/testcases/VIM/OpenStack/CI/libraries/run_rally-cert.py
@@ -23,6 +23,8 @@ import yaml
import requests
import sys
import novaclient.v2.client as novaclient
+from glanceclient import client as glanceclient
+from keystoneclient.v2_0 import client as keystoneclient
""" tests configuration """
tests = ['authenticate', 'glance', 'cinder', 'heat', 'keystone',
@@ -130,16 +132,6 @@ def get_task_id(cmd_raw):
return None
-def create_glance_image(path, name, disk_format):
- """
- Create a glance image given the absolute path of the image, its name and the disk format
- """
- cmd = ("glance image-create --name " + name + " --visibility public "
- "--disk-format " + disk_format + " --container-format bare --file " + path)
- functest_utils.execute_command(cmd, logger)
- return True
-
-
def task_succeed(json_raw):
"""
Parse JSON from rally JSON results
@@ -162,7 +154,7 @@ def task_succeed(json_raw):
def build_task_args(test_file_name):
task_args = {'service_list': [test_file_name]}
- task_args['smoke'] = False
+ task_args['smoke'] = False
task_args['image_name'] = GLANCE_IMAGE_NAME
task_args['flavor_name'] = FLAVOR_NAME
task_args['glance_image_location'] = GLANCE_IMAGE_LOCATION
@@ -247,20 +239,6 @@ def run_task(test_name):
print 'Test KO'
-def delete_glance_image(name):
- cmd = ("glance image-delete $(glance image-list | grep %s "
- "| awk '{print $2}' | head -1)" % name)
- functest_utils.execute_command(cmd, logger)
- return True
-
-
-def cleanup(nova):
- logger.info("Cleaning up...")
- logger.debug("Deleting image...")
- delete_glance_image(GLANCE_IMAGE_NAME)
- return True
-
-
def main():
# configure script
if not (args.test_name in tests):
@@ -269,11 +247,19 @@ def main():
creds_nova = functest_utils.get_credentials("nova")
nova_client = novaclient.Client(**creds_nova)
+ creds_keystone = functest_utils.get_credentials("keystone")
+ keystone_client = keystoneclient.Client(**creds_keystone)
+ glance_endpoint = keystone_client.service_catalog.url_for(service_type='image',
+ endpoint_type='publicURL')
+ glance_client = glanceclient.Client(1, glance_endpoint,
+ token=keystone_client.auth_token)
logger.debug("Creating image '%s' from '%s'..." % (GLANCE_IMAGE_NAME, GLANCE_IMAGE_PATH))
- create_glance_image(GLANCE_IMAGE_PATH, GLANCE_IMAGE_NAME, GLANCE_IMAGE_FORMAT)
-
-
+ image_id = functest_utils.create_glance_image(glance_client,
+ GLANCE_IMAGE_NAME,GLANCE_IMAGE_PATH)
+ if not image_id:
+ logger.error("Failed to create a Glance image...")
+ exit(-1)
# Check if the given image exists
try:
nova_client.images.find(name=GLANCE_IMAGE_NAME)
@@ -295,7 +281,9 @@ def main():
print(args.test_name)
run_task(args.test_name)
- cleanup(nova_client)
+ logger.debug("Deleting image...")
+ if not functest_utils.delete_glance_image(nova_client, image_id):
+ logger.error("Error deleting the glance image")
if __name__ == '__main__':
main()