summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose Lausuch <jose.lausuch@ericsson.com>2016-12-21 10:32:03 +0000
committerboucherv <valentin.boucher@orange.com>2016-12-21 15:12:12 +0100
commit3542fb76b0034228e588d395fd8a64df4eff8100 (patch)
tree1b4c5050c0754b3e95f2759c1be3a0b5d99fac3b
parent266e29ce1eb02bf8f97ada361d759d41567cce73 (diff)
parent231b742d9db18ee347d786dd6cb42c0ca67ad5bc (diff)
Updated vims to support keystone v3
Adding the choice, into openstack_utils, to get openstack client with environment credentials or with a specific credentials (new user/tenant..) JIRA: FUNCTEST-529 Change-Id: I295808311de40f37a07b5a831852876a51f276f3 Signed-off-by: boucherv <valentin.boucher@orange.com>
-rwxr-xr-xfunctest/ci/config_functest.yaml28
-rw-r--r--functest/core/feature_base.py4
-rw-r--r--functest/opnfv_tests/openstack/snaps/smoke.py2
-rwxr-xr-xfunctest/opnfv_tests/openstack/vping/vping_base.py43
-rwxr-xr-xfunctest/opnfv_tests/vnf/ims/vims.py51
-rw-r--r--functest/utils/functest_constants.py56
-rw-r--r--functest/utils/functest_utils.py2
-rwxr-xr-xfunctest/utils/openstack_utils.py40
8 files changed, 108 insertions, 118 deletions
diff --git a/functest/ci/config_functest.yaml b/functest/ci/config_functest.yaml
index 11ff7fdb5..b6dde1148 100755
--- a/functest/ci/config_functest.yaml
+++ b/functest/ci/config_functest.yaml
@@ -1,7 +1,7 @@
general:
- directories:
+ dir:
# Relative to the path where the repo is cloned:
- dir_vping: functest/opnfv_tests/openstack/vping
+ vping: functest/opnfv_tests/openstack/vping
dir_odl: functest/opnfv_tests/sdn/odl
dir_rally: functest/opnfv_tests/openstack/rally
dir_tempest_cases: functest/opnfv_tests/openstack/tempest/custom_tests
@@ -12,7 +12,7 @@ general:
# Absolute path
dir_home: /home/opnfv
dir_repos: /home/opnfv/repos
- dir_repo_functest: /home/opnfv/repos/functest
+ repo_functest: /home/opnfv/repos/functest
dir_repo_rally: /home/opnfv/repos/rally
dir_repo_tempest: /home/opnfv/repos/tempest
dir_repo_releng: /home/opnfv/repos/releng
@@ -27,11 +27,11 @@ general:
dir_repo_parser: /home/opnfv/repos/parser
dir_repo_domino: /home/opnfv/repos/domino
dir_repo_snaps: /home/opnfv/repos/snaps
- dir_functest: /home/opnfv/functest
- dir_functest_test: /home/opnfv/repos/functest/functest/opnfv_tests
- dir_results: /home/opnfv/functest/results
- dir_functest_conf: /home/opnfv/functest/conf
- dir_functest_data: /home/opnfv/functest/data
+ functest: /home/opnfv/functest
+ functest_test: /home/opnfv/repos/functest/functest/opnfv_tests
+ results: /home/opnfv/functest/results
+ functest_conf: /home/opnfv/functest/conf
+ functest_data: /home/opnfv/functest/data
dir_vIMS_data: /home/opnfv/functest/data/vIMS/
dir_rally_inst: /home/opnfv/.rally
@@ -75,12 +75,12 @@ vping:
vm_name_1: opnfv-vping-1
vm_name_2: opnfv-vping-2
image_name: functest-vping
- vping_private_net_name: vping-net
- vping_private_subnet_name: vping-subnet
- vping_private_subnet_cidr: 192.168.130.0/24
- vping_router_name: vping-router
- vping_sg_name: vPing-sg
- vping_sg_descr: Security group for vPing test case
+ private_net_name: vping-net
+ private_subnet_name: vping-subnet
+ private_subnet_cidr: 192.168.130.0/24
+ router_name: vping-router
+ sg_name: vPing-sg
+ sg_desc: Security group for vPing test case
onos_sfc:
image_base_url: http://artifacts.opnfv.org/sfc/demo
diff --git a/functest/core/feature_base.py b/functest/core/feature_base.py
index 01a27f305..780170d44 100644
--- a/functest/core/feature_base.py
+++ b/functest/core/feature_base.py
@@ -11,7 +11,7 @@ class FeatureBase(base.TestcaseBase):
self.project_name = project
self.case_name = case
self.cmd = cmd
- self.repo = self.get_conf('general.directories.{}'.format(repo))
+ self.repo = self.get_conf('general.dir.{}'.format(repo))
self.result_file = self.get_result_file()
self.logger = ft_logger.Logger(project).getLogger()
@@ -44,7 +44,7 @@ class FeatureBase(base.TestcaseBase):
return exit_code
def get_result_file(self):
- dir = self.get_conf('general.directories.dir_results')
+ dir = self.get_conf('general.dir.results')
return "{}/{}.log".format(dir, self.project_name)
def log_results(self):
diff --git a/functest/opnfv_tests/openstack/snaps/smoke.py b/functest/opnfv_tests/openstack/snaps/smoke.py
index f66c17ff2..691f81384 100644
--- a/functest/opnfv_tests/openstack/snaps/smoke.py
+++ b/functest/opnfv_tests/openstack/snaps/smoke.py
@@ -33,7 +33,7 @@ class SnapsSmoke(PyTestSuiteRunner):
# SNAPS repository and are found relative to that path
if use_fip:
snaps_dir = ft_utils.get_functest_config(
- 'general.directories.dir_repo_snaps') + '/snaps'
+ 'general.dir.dir_repo_snaps') + '/snaps'
os.chdir(snaps_dir)
test_suite_builder.add_openstack_integration_tests(
diff --git a/functest/opnfv_tests/openstack/vping/vping_base.py b/functest/opnfv_tests/openstack/vping/vping_base.py
index e467dd9f5..a5309bd44 100755
--- a/functest/opnfv_tests/openstack/vping/vping_base.py
+++ b/functest/opnfv_tests/openstack/vping/vping_base.py
@@ -12,43 +12,38 @@ import pprint
import time
from datetime import datetime
-import functest.utils.functest_utils as ft_utils
-import functest.utils.functest_constants as ft_constants
-import functest.utils.openstack_utils as os_utils
import functest.core.testcase_base as testcase_base
+import functest.utils.openstack_utils as os_utils
+from functest.utils.constants import CONST
class VPingBase(testcase_base.TestcaseBase):
def __init__(self):
- def get_conf(parameter):
- return ft_utils.get_functest_config(parameter)
-
super(VPingBase, self).__init__()
self.logger = None
- self.functest_repo = ft_constants.FUNCTEST_REPO_DIR
- self.repo = get_conf('general.directories.dir_vping')
- self.vm1_name = get_conf('vping.vm_name_1')
- self.vm2_name = get_conf('vping.vm_name_2')
+ self.functest_repo = CONST.dir_repo_functest
+ self.repo = CONST.dir_vping
+ self.vm1_name = CONST.vping_vm_name_1
+ self.vm2_name = CONST.vping_vm_name_2
self.vm_boot_timeout = 180
self.vm_delete_timeout = 100
- self.ping_timeout = get_conf('vping.ping_timeout')
+ self.ping_timeout = CONST.vping_ping_timeout
- self.image_name = get_conf('vping.image_name')
- self.image_filename = get_conf('general.openstack.image_file_name')
- self.image_format = get_conf('general.openstack.image_disk_format')
- self.image_path = ("%s/%s" %
- (get_conf('general.directories.dir_functest_data'),
- self.image_filename))
+ self.image_name = CONST.vping_image_name
+ self.image_filename = CONST.openstack_image_file_name
+ self.image_format = CONST.openstack_image_disk_format
+ self.image_path = os.path.join(CONST.dir_functest_data,
+ self.image_filename)
- self.flavor_name = get_conf('vping.vm_flavor')
+ self.flavor_name = CONST.vping_vm_flavor
# NEUTRON Private Network parameters
- self.private_net_name = get_conf('vping.vping_private_net_name')
- self.private_subnet_name = get_conf('vping.vping_private_subnet_name')
- self.private_subnet_cidr = get_conf('vping.vping_private_subnet_cidr')
- self.router_name = get_conf('vping.vping_router_name')
- self.sg_name = get_conf('vping.vping_sg_name')
- self.sg_desc = get_conf('vping.vping_sg_descr')
+ self.private_net_name = CONST.vping_private_net_name
+ self.private_subnet_name = CONST.vping_private_subnet_name
+ self.private_subnet_cidr = CONST.vping_private_subnet_cidr
+ self.router_name = CONST.vping_router_name
+ self.sg_name = CONST.vping_sg_name
+ self.sg_desc = CONST.vping_sg_desc
self.neutron_client = os_utils.get_neutron_client()
self.glance_client = os_utils.get_glance_client()
self.nova_client = os_utils.get_nova_client()
diff --git a/functest/opnfv_tests/vnf/ims/vims.py b/functest/opnfv_tests/vnf/ims/vims.py
index fe888b698..15981f512 100755
--- a/functest/opnfv_tests/vnf/ims/vims.py
+++ b/functest/opnfv_tests/vnf/ims/vims.py
@@ -19,10 +19,7 @@ import subprocess
import time
import argparse
-import keystoneclient.v2_0.client as ksclient
-import novaclient.client as nvclient
import requests
-from neutronclient.v2_0 import client as ntclient
import functest.utils.functest_logger as ft_logger
import functest.utils.functest_utils as ft_utils
@@ -242,17 +239,15 @@ def main():
if not os.path.exists(VIMS_DATA_DIR):
os.makedirs(VIMS_DATA_DIR)
- ks_creds = os_utils.get_credentials("keystone")
- nv_creds = os_utils.get_credentials("nova")
- nt_creds = os_utils.get_credentials("neutron")
+ creds = os_utils.get_credentials()
logger.info("Prepare OpenStack plateform (create tenant and user)")
- keystone = ksclient.Client(**ks_creds)
+ keystone = os_utils.get_keystone_client()
- user_id = os_utils.get_user_id(keystone, ks_creds['username'])
+ user_id = os_utils.get_user_id(keystone, creds['username'])
if user_id == '':
step_failure("init", "Error : Failed to get id of " +
- ks_creds['username'])
+ creds['username'])
tenant_id = os_utils.create_tenant(
keystone, VIMS_TENANT_NAME, VIMS_TENANT_DESCRIPTION)
@@ -271,7 +266,7 @@ def main():
if not os_utils.add_role_user(keystone, user_id, role_id, tenant_id):
logger.error("Error : Failed to add %s on tenant" %
- ks_creds['username'])
+ creds['username'])
user_id = os_utils.create_user(
keystone, VIMS_TENANT_NAME, VIMS_TENANT_NAME, None, tenant_id)
@@ -279,18 +274,10 @@ def main():
logger.error("Error : Failed to create %s user" % VIMS_TENANT_NAME)
logger.info("Update OpenStack creds informations")
- ks_creds.update({
+ creds.update({
"username": VIMS_TENANT_NAME,
"password": VIMS_TENANT_NAME,
- "tenant_name": VIMS_TENANT_NAME,
- })
-
- nt_creds.update({
- "tenant_name": VIMS_TENANT_NAME,
- })
-
- nv_creds.update({
- "project_id": VIMS_TENANT_NAME,
+ "tenant": VIMS_TENANT_NAME,
})
logger.info("Upload some OS images if it doesn't exist")
@@ -314,10 +301,8 @@ def main():
"Error : Failed to find or upload required OS "
"image for this deployment")
- nova = nvclient.Client("2", **nv_creds)
-
logger.info("Update security group quota for this tenant")
- neutron = ntclient.Client(**nt_creds)
+ neutron = os_utils.get_neutron_client(creds)
if not os_utils.update_sg_quota(neutron, tenant_id, 50, 100):
step_failure(
"init",
@@ -325,17 +310,22 @@ def main():
VIMS_TENANT_NAME)
# ############### CLOUDIFY INITIALISATION ################
- public_auth_url = keystone.service_catalog.url_for(
- service_type='identity', endpoint_type='publicURL')
+ public_auth_url = os_utils.get_endpoint('identity')
cfy = Orchestrator(VIMS_DATA_DIR, CFY_INPUTS)
- cfy.set_credentials(username=ks_creds['username'], password=ks_creds[
- 'password'], tenant_name=ks_creds['tenant_name'],
+ if 'tenant_name' in creds.keys():
+ tenant_name = creds['tenant_name']
+ elif 'project_name' in creds.keys():
+ tenant_name = creds['project_name']
+
+ cfy.set_credentials(username=creds['username'],
+ password=creds['password'],
+ tenant_name=tenant_name,
auth_url=public_auth_url)
logger.info("Collect flavor id for cloudify manager server")
- nova = nvclient.Client("2", **nv_creds)
+ nova = os_utils.get_nova_client(creds)
flavor_name = "m1.large"
flavor_id = os_utils.get_flavor_id(nova, flavor_name)
@@ -416,7 +406,6 @@ def main():
cw = Clearwater(CW_INPUTS, cfy, logger)
logger.info("Collect flavor id for all clearwater vm")
- nova = nvclient.Client("2", **nv_creds)
flavor_name = "m1.small"
flavor_id = os_utils.get_flavor_id(nova, flavor_name)
@@ -490,10 +479,6 @@ def main():
if args.noclean:
exit(0)
- ks_creds = os_utils.get_credentials("keystone")
-
- keystone = ksclient.Client(**ks_creds)
-
logger.info("Removing %s tenant .." % CFY_INPUTS['keystone_tenant_name'])
tenant_id = os_utils.get_tenant_id(
keystone, CFY_INPUTS['keystone_tenant_name'])
diff --git a/functest/utils/functest_constants.py b/functest/utils/functest_constants.py
index 2664ace1f..a39d33ac8 100644
--- a/functest/utils/functest_constants.py
+++ b/functest/utils/functest_constants.py
@@ -60,25 +60,25 @@ def get_value(functest_config_key, env_variable):
return constant
-HOME = get_value('general.directories.dir_home', 'HOME')
-REPOS_DIR = get_value('general.directories.dir_repos', 'REPOS_DIR')
-FUNCTEST_BASE_DIR = get_value('general.directories.dir_functest',
+HOME = get_value('general.dir.dir_home', 'HOME')
+REPOS_DIR = get_value('general.dir.dir_repos', 'REPOS_DIR')
+FUNCTEST_BASE_DIR = get_value('general.dir.functest',
'FUNCTEST_BASE_DIR')
-FUNCTEST_REPO_DIR = get_value('general.directories.dir_repo_functest',
+FUNCTEST_REPO_DIR = get_value('general.dir.repo_functest',
'FUNCTEST_REPO_DIR')
-FUNCTEST_TEST_DIR = get_value('general.directories.dir_functest_test',
+FUNCTEST_TEST_DIR = get_value('general.dir.functest_test',
'FUNCTEST_TEST_DIR')
-FUNCTEST_CONF_DIR = get_value('general.directories.dir_functest_conf',
+FUNCTEST_CONF_DIR = get_value('general.dir.functest_conf',
'FUNCTEST_CONF_DIR')
-FUNCTEST_DATA_DIR = get_value('general.directories.dir_functest_data',
+FUNCTEST_DATA_DIR = get_value('general.dir.functest_data',
'FUNCTEST_DATA_DIR')
-FUNCTEST_RESULTS_DIR = get_value('general.directories.dir_results',
+FUNCTEST_RESULTS_DIR = get_value('general.dir.results',
'FUNCTEST_RESULTS_DIR')
FUNCTEST_TESTCASES_YAML = get_value('general.functest.testcases_yaml',
'FUNCTEST_TESTCASES_YAML')
RALLY_DEPLOYMENT_NAME = get_value('rally.deployment_name',
'RALLY_DEPLOYMENT_NAME')
-TEMPEST_REPO_DIR = get_value('general.directories.dir_repo_tempest',
+TEMPEST_REPO_DIR = get_value('general.dir.dir_repo_tempest',
'TEMPEST_REPO_DIR')
ENV_FILE = os.path.join(FUNCTEST_CONF_DIR, "env_active")
@@ -87,22 +87,22 @@ OPENSTACK_CREDS = get_value('general.openstack.creds', 'creds')
OPENSTACK_SNAPSHOT_FILE = get_value('general.openstack.snapshot_file',
'OPENSTACK_SNAPSHOT_FILE')
-DOMINO_REPO_DIR = get_value('general.directories.dir_repo_domino',
+DOMINO_REPO_DIR = get_value('general.dir.dir_repo_domino',
'DOMINO_REPO_DIR')
-SDNVPN_REPO_DIR = get_value('general.directories.dir_repo_sdnvpn',
+SDNVPN_REPO_DIR = get_value('general.dir.dir_repo_sdnvpn',
'SDNVPN_REPO_DIR')
-SFC_REPO_DIR = get_value('general.directories.dir_repo_sfc',
+SFC_REPO_DIR = get_value('general.dir.dir_repo_sfc',
'SFC_REPO_DIR')
ONOS_SFC_IMAGE_NAME = get_value('onos_sfc.image_name',
'ONOS_SFC_IMAGE_NAME')
ONOS_SFC_IMAGE_FILENAME = get_value('onos_sfc.image_file_name',
'ONOS_SFC_IMAGE_FILENAME')
-ONOS_SFC_RELATIVE_PATH = get_value('general.directories.dir_onos_sfc',
+ONOS_SFC_RELATIVE_PATH = get_value('general.dir.dir_onos_sfc',
'ONOS_SFC_RELATIVE_PATH')
ONOS_SFC_IMAGE_BASE_URL = get_value('onos_sfc.image_base_url',
'ONOS_SFC_IMAGE_BASE_URL')
-RALLY_RELATIVE_PATH = get_value('general.directories.dir_rally',
+RALLY_RELATIVE_PATH = get_value('general.dir.dir_rally',
'RALLY_RELATIVE_PATH')
RALLY_PRIVATE_NET_NAME = get_value('rally.network_name',
'RALLY_PRIVATE_NET_NAME')
@@ -111,7 +111,7 @@ RALLY_PRIVATE_SUBNET_NAME = get_value('rally.subnet_name',
RALLY_PRIVATE_SUBNET_CIDR = get_value('rally.subnet_cidr',
'RALLY_PRIVATE_SUBNET_CIDR')
RALLY_ROUTER_NAME = get_value('rally.router_name', 'RALLY_ROUTER_NAME')
-RALLY_INSTALLATION_DIR = get_value('general.directories.dir_rally_inst',
+RALLY_INSTALLATION_DIR = get_value('general.dir.dir_rally_inst',
'RALLY_INSTALLATION_DIR')
GLANCE_IMAGE_NAME = get_value('general.openstack.image_name',
'GLANCE_IMAGE_NAME')
@@ -149,24 +149,24 @@ TEMPEST_USE_CUSTOM_IMAGES = get_value('tempest.use_custom_images',
'TEMPEST_USE_CUSTOM_IMAGES')
TEMPEST_USE_CUSTOM_FLAVORS = get_value('tempest.use_custom_flavors',
'TEMPEST_USE_CUSTOM_FLAVORS')
-TEMPEST_TEST_LIST_DIR = get_value('general.directories.dir_tempest_cases',
+TEMPEST_TEST_LIST_DIR = get_value('general.dir.dir_tempest_cases',
'TEMPEST_TEST_LIST_DIR')
NAME_VM_1 = get_value('vping.vm_name_1', 'NAME_VM_1')
NAME_VM_2 = get_value('vping.vm_name_2', 'NAME_VM_2')
PING_TIMEOUT = get_value('vping.ping_timeout', 'PING_TIMEOUT')
VPING__IMAGE_NAME = get_value('vping.image_name', 'VPING__IMAGE_NAME')
VPING_VM_FLAVOR = get_value('vping.vm_flavor', 'VPING_VM_FLAVOR')
-VPING_PRIVATE_NET_NAME = get_value('vping.vping_private_net_name',
+VPING_PRIVATE_NET_NAME = get_value('vping.private_net_name',
'VPING_PRIVATE_NET_NAME')
-VPING_PRIVATE_SUBNET_NAME = get_value('vping.vping_private_subnet_name',
+VPING_PRIVATE_SUBNET_NAME = get_value('vping.private_subnet_name',
'VPING_PRIVATE_SUBNET_NAME')
-VPING_PRIVATE_SUBNET_CIDR = get_value('vping.vping_private_subnet_cidr',
+VPING_PRIVATE_SUBNET_CIDR = get_value('vping.private_subnet_cidr',
'VPING_PRIVATE_SUBNET_CIDR')
-VPING_ROUTER_NAME = get_value('vping.vping_router_name',
+VPING_ROUTER_NAME = get_value('vping.router_name',
'VPING_ROUTER_NAME')
-VPING_SECGROUP_NAME = get_value('vping.vping_sg_name',
+VPING_SECGROUP_NAME = get_value('vping.sg_name',
'VPING_SECGROUP_NAME')
-VPING_SECGROUP_DESCR = get_value('vping.vping_sg_descr',
+VPING_SECGROUP_DESCR = get_value('vping.sg_desc',
'VPING_SECGROUP_DESCR')
ONOSBENCH_USERNAME = get_value('ONOS.general.onosbench_username',
'ONOSBENCH_USERNAME')
@@ -192,7 +192,7 @@ ONOS_INSTALLER_MASTER_USERNAME = get_value(
ONOS_INSTALLER_MASTER_PASSWORD = get_value(
'ONOS.environment.installer_master_password',
'ONOS_INSTALLER_MASTER_PASSWORD')
-PROMISE_REPO_DIR = get_value('general.directories.dir_repo_promise',
+PROMISE_REPO_DIR = get_value('general.dir.dir_repo_promise',
'PROMISE_REPO_DIR')
PROMISE_TENANT_NAME = get_value('promise.tenant_name',
'PROMISE_TENANT_NAME')
@@ -217,9 +217,9 @@ PROMISE_SUBNET_CIDR = get_value('promise.subnet_cidr',
'PROMISE_SUBNET_CIDR')
PROMISE_ROUTER_NAME = get_value('promise.router_name',
'PROMISE_ROUTER_NAME')
-DOCTOR_REPO_DIR = get_value('general.directories.dir_repo_doctor',
+DOCTOR_REPO_DIR = get_value('general.dir.dir_repo_doctor',
'DOCTOR_REPO_DIR')
-COPPER_REPO_DIR = get_value('general.directories.dir_repo_copper',
+COPPER_REPO_DIR = get_value('general.dir.dir_repo_copper',
'COPPER_REPO_DIR')
EXAMPLE_INSTANCE_NAME = get_value('example.example_vm_name',
'EXAMPLE_INSTANCE_NAME')
@@ -240,9 +240,9 @@ EXAMPLE_SECGROUP_NAME = get_value('example.example_sg_name',
'EXAMPLE_SECGROUP_NAME')
EXAMPLE_SECGROUP_DESCR = get_value('example.example_sg_descr',
'EXAMPLE_SECGROUP_DESCR')
-VIMS_DATA_DIR = get_value('general.directories.dir_vIMS_data',
+VIMS_DATA_DIR = get_value('general.dir.dir_vIMS_data',
'VIMS_DATA_DIR')
-VIMS_TEST_DIR = get_value('general.directories.dir_repo_vims_test',
+VIMS_TEST_DIR = get_value('general.dir.dir_repo_vims_test',
'VIMS_TEST_DIR')
VIMS_TENANT_NAME = get_value('vIMS.general.tenant_name',
'VIMS_TENANT_NAME')
@@ -260,5 +260,5 @@ CW_DEPLOYMENT_NAME = get_value('vIMS.clearwater.deployment-name',
CW_INPUTS = get_value('vIMS.clearwater.inputs', 'CW_INPUTS')
CW_REQUIERMENTS = get_value('vIMS.clearwater.requierments',
'CW_REQUIERMENTS')
-PARSER_REPO_DIR = get_value('general.directories.dir_repo_parser',
+PARSER_REPO_DIR = get_value('general.dir.dir_repo_parser',
'PARSER_REPO_DIR')
diff --git a/functest/utils/functest_utils.py b/functest/utils/functest_utils.py
index b1e4d3cdb..e4845c629 100644
--- a/functest/utils/functest_utils.py
+++ b/functest/utils/functest_utils.py
@@ -326,7 +326,7 @@ def get_deployment_dir():
Returns current Rally deployment directory
"""
deployment_name = get_functest_config('rally.deployment_name')
- rally_dir = get_functest_config('general.directories.dir_rally_inst')
+ rally_dir = get_functest_config('general.dir.dir_rally_inst')
cmd = ("rally deployment list | awk '/" + deployment_name +
"/ {print $2}'")
p = subprocess.Popen(cmd, shell=True,
diff --git a/functest/utils/openstack_utils.py b/functest/utils/openstack_utils.py
index ec784121b..38a30cb33 100755
--- a/functest/utils/openstack_utils.py
+++ b/functest/utils/openstack_utils.py
@@ -86,7 +86,7 @@ def get_env_cred_dict():
return env_cred_dict
-def get_credentials():
+def get_credentials(other_creds={}):
"""Returns a creds dictionary filled with parsed from env
"""
creds = {}
@@ -99,6 +99,16 @@ def get_credentials():
else:
creds_key = env_cred_dict.get(envvar)
creds.update({creds_key: os.getenv(envvar)})
+
+ if 'tenant' in other_creds.keys():
+ if is_keystone_v3():
+ tenant = 'project_name'
+ else:
+ tenant = 'tenant_name'
+ other_creds[tenant] = other_creds.pop('tenant')
+
+ creds.update(other_creds)
+
return creds
@@ -138,9 +148,9 @@ def get_credentials_for_rally():
return rally_conf
-def get_session_auth():
+def get_session_auth(other_creds={}):
loader = loading.get_plugin_loader('password')
- creds = get_credentials()
+ creds = get_credentials(other_creds)
auth = loader.load_from_options(**creds)
return auth
@@ -152,8 +162,8 @@ def get_endpoint(service_type, endpoint_type='publicURL'):
endpoint_type=endpoint_type)
-def get_session():
- auth = get_session_auth()
+def get_session(other_creds={}):
+ auth = get_session_auth(other_creds)
return session.Session(auth=auth)
@@ -169,8 +179,8 @@ def get_keystone_client_version():
return DEFAULT_API_VERSION
-def get_keystone_client():
- sess = get_session()
+def get_keystone_client(other_creds={}):
+ sess = get_session(other_creds)
return keystoneclient.Client(get_keystone_client_version(), session=sess)
@@ -183,8 +193,8 @@ def get_nova_client_version():
return DEFAULT_API_VERSION
-def get_nova_client():
- sess = get_session()
+def get_nova_client(other_creds={}):
+ sess = get_session(other_creds)
return novaclient.Client(get_nova_client_version(), session=sess)
@@ -197,8 +207,8 @@ def get_cinder_client_version():
return DEFAULT_API_VERSION
-def get_cinder_client():
- sess = get_session()
+def get_cinder_client(other_creds={}):
+ sess = get_session(other_creds)
return cinderclient.Client(get_cinder_client_version(), session=sess)
@@ -211,8 +221,8 @@ def get_neutron_client_version():
return DEFAULT_API_VERSION
-def get_neutron_client():
- sess = get_session()
+def get_neutron_client(other_creds={}):
+ sess = get_session(other_creds)
return neutronclient.Client(get_neutron_client_version(), session=sess)
@@ -224,8 +234,8 @@ def get_glance_client_version():
return DEFAULT_API_VERSION
-def get_glance_client():
- sess = get_session()
+def get_glance_client(other_creds={}):
+ sess = get_session(other_creds)
return glanceclient.Client(get_glance_client_version(), session=sess)