diff options
author | helenyao <yaohelan@huawei.com> | 2016-12-08 04:36:55 -0500 |
---|---|---|
committer | helenyao <yaohelan@huawei.com> | 2016-12-08 04:36:55 -0500 |
commit | 77458d72140c0e2a4ffc608bb36f64249abf2777 (patch) | |
tree | 2447ef9da4dd0e12d29ab9f7a848c9a294104f5f | |
parent | ed96a8b6e3440a85d9047b37207b161d3ea37f2b (diff) |
Update the logic to support both Newton and Mitaka
JIRA: FUNCTEST-645
RC file is quite different between Newton and Mitaka.
The change is to support both version.
Change-Id: I846e8bc4b4c8b7caf4bcb26c8453e1fc5d1cc0f4
Signed-off-by: helenyao <yaohelan@huawei.com>
-rwxr-xr-x | functest/utils/openstack_utils.py | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/functest/utils/openstack_utils.py b/functest/utils/openstack_utils.py index df6fb5d1a..10aaf5034 100755 --- a/functest/utils/openstack_utils.py +++ b/functest/utils/openstack_utils.py @@ -56,8 +56,19 @@ def get_credentials(service): """ creds = {} + keystone_api_version = os.getenv('OS_IDENTITY_API_VERSION') + if (keystone_api_version is None or + keystone_api_version == '2'): + keystone_v3 = False + tenant_env = 'OS_TENANT_NAME' + tenant = 'tenant_name' + else: + keystone_v3 = True + tenant_env = 'OS_PROJECT_NAME' + tenant = 'project_name' + # Check that the env vars exists: - envvars = ('OS_USERNAME', 'OS_PASSWORD', 'OS_AUTH_URL', 'OS_TENANT_NAME') + envvars = ('OS_USERNAME', 'OS_PASSWORD', 'OS_AUTH_URL', tenant_env) for envvar in envvars: if os.getenv(envvar) is None: raise MissingEnvVar(envvar) @@ -69,7 +80,6 @@ def get_credentials(service): tenant = "project_id" else: password = "password" - tenant = "tenant_name" # The most common way to pass these info to the script is to do it through # environment variables. @@ -77,8 +87,18 @@ def get_credentials(service): "username": os.environ.get("OS_USERNAME"), password: os.environ.get("OS_PASSWORD"), "auth_url": os.environ.get("OS_AUTH_URL"), - tenant: os.environ.get("OS_TENANT_NAME") + tenant: os.environ.get(tenant_env) }) + if keystone_v3: + if os.getenv('OS_USER_DOMAIN_NAME') is not None: + creds.update({ + "user_domain_name": os.getenv('OS_USER_DOMAIN_NAME') + }) + if os.getenv('OS_PROJECT_DOMAIN_NAME') is not None: + creds.update({ + "project_domain_name": os.getenv('OS_PROJECT_DOMAIN_NAME') + }) + if os.getenv('OS_ENDPOINT_TYPE') is not None: creds.update({ "endpoint_type": os.environ.get("OS_ENDPOINT_TYPE") |