From addc7f7318147c29de474813b00ae40882ca9662 Mon Sep 17 00:00:00 2001 From: "jose.lausuch" Date: Wed, 13 Jul 2016 12:07:21 +0200 Subject: Use common way to get the openstack clients Instead of repeating the code in all the scripts and importing the openstack libraries, the clients shall be given by openstack utils, which is its purpose JIRA: FUNCTEST-163 Change-Id: I1ccc05a3af44ee1ab5938ea9e4e01dbe55f4816d Signed-off-by: jose.lausuch --- testcases/OpenStack/tempest/run_tempest.py | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'testcases/OpenStack/tempest/run_tempest.py') diff --git a/testcases/OpenStack/tempest/run_tempest.py b/testcases/OpenStack/tempest/run_tempest.py index ab79a876..c773091b 100755 --- a/testcases/OpenStack/tempest/run_tempest.py +++ b/testcases/OpenStack/tempest/run_tempest.py @@ -13,6 +13,7 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 # +import ConfigParser import argparse import os import re @@ -20,16 +21,12 @@ import shutil import subprocess import sys import time -import yaml -import ConfigParser - -import keystoneclient.v2_0.client as ksclient -from glanceclient import client as glanceclient -from neutronclient.v2_0 import client as neutronclient import functest.utils.functest_logger as ft_logger import functest.utils.functest_utils as ft_utils import functest.utils.openstack_utils as os_utils +import yaml + modes = ['full', 'smoke', 'baremetal', 'compute', 'data_processing', 'identity', 'image', 'network', 'object_storage', 'orchestration', @@ -123,23 +120,24 @@ def get_info(file_result): def create_tempest_resources(): - ks_creds = os_utils.get_credentials("keystone") + + 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") - keystone = ksclient.Client(**ks_creds) - tenant_id = os_utils.create_tenant(keystone, + tenant_id = os_utils.create_tenant(keystone_client, TENANT_NAME, TENANT_DESCRIPTION) if tenant_id == '': logger.error("Error : Failed to create %s tenant" % TENANT_NAME) - user_id = os_utils.create_user(keystone, USER_NAME, USER_PASSWORD, + user_id = os_utils.create_user(keystone_client, USER_NAME, USER_PASSWORD, None, tenant_id) if user_id == '': logger.error("Error : Failed to create %s user" % USER_NAME) logger.debug("Creating private network for Tempest suite") - creds_neutron = os_utils.get_credentials("neutron") - neutron_client = neutronclient.Client(**creds_neutron) network_dic = os_utils.create_network_full(logger, neutron_client, PRIVATE_NET_NAME, @@ -159,10 +157,6 @@ def create_tempest_resources(): exit(-1) logger.debug("Creating image for Tempest suite") - glance_endpoint = keystone.service_catalog.url_for( - service_type='image', endpoint_type='publicURL') - glance_client = glanceclient.Client(1, glance_endpoint, - token=keystone.auth_token) # Check if the given image exists image_id = os_utils.get_image_id(glance_client, GLANCE_IMAGE_NAME) if image_id != '': @@ -367,7 +361,7 @@ def run_tempest(OPTION): error_logs = "" for match in re.findall('(.*?)[. ]*FAILED', output): - error_logs += match + error_logs += match # Generate json results for DB json_results = {"timestart": time_start, "duration": dur_sec_int, -- cgit 1.2.3-korg