summaryrefslogtreecommitdiffstats
path: root/vnftest/common
diff options
context:
space:
mode:
authorMoshe <moshehoa@amdocs.com>2018-03-20 10:51:42 +0200
committerMoshe <moshehoa@amdocs.com>2018-03-20 10:55:28 +0200
commit05acf08ad5ed275e41402115acf177f8c49764f8 (patch)
tree4fed9f3bc6a30004ae395749d669d64598d8865f /vnftest/common
parent99663bada7fccdd87d74541d2de2e414b3e61fce (diff)
New test case - instantiate vnf
Issue-ID: VNFSDK-181 Change-Id: Ic160a125452473a228d8861ecc457e3c021a2dfb Signed-off-by: Moshe <moshehoa@amdocs.com>
Diffstat (limited to 'vnftest/common')
-rw-r--r--vnftest/common/openstack_utils.py61
1 files changed, 29 insertions, 32 deletions
diff --git a/vnftest/common/openstack_utils.py b/vnftest/common/openstack_utils.py
index 954df2e..c97c1c2 100644
--- a/vnftest/common/openstack_utils.py
+++ b/vnftest/common/openstack_utils.py
@@ -33,44 +33,41 @@ log = logging.getLogger(__name__)
DEFAULT_HEAT_API_VERSION = '1'
DEFAULT_API_VERSION = '2'
+creds = {}
+
# *********************************************
# CREDENTIALS
# *********************************************
def get_credentials():
"""Returns a creds dictionary filled with parsed from env"""
- 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'
-
- # The most common way to pass these info to the script is to do it
- # through environment variables.
- creds.update({
- "username": os.environ.get("OS_USERNAME"),
- "password": os.environ.get("OS_PASSWORD"),
- "auth_url": os.environ.get("OS_AUTH_URL"),
- 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 len(creds) == 0:
+ # The most common way to pass these info to the script is to do it
+ # through environment variables.
+ keystone_api_version = os.getenv('OS_IDENTITY_API_VERSION')
+
+ if keystone_api_version is None or keystone_api_version == '2':
+ keystone_v3 = False
+ creds['tenant_name'] = os.environ.get('OS_TENANT_NAME')
+ else:
+ keystone_v3 = True
+ creds['tenant_name'] = os.environ.get('OS_PROJECT_NAME')
+ creds['project_name'] = os.environ.get('OS_PROJECT_NAME')
+
+ creds["username"] = os.environ.get("OS_USERNAME")
+ creds["password"] = os.environ.get("OS_PASSWORD")
+ creds["auth_url"] = os.environ.get("OS_AUTH_URL")
+ creds["tenant_id"] = os.environ.get("OS_TENANT_ID")
+
+ 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')
+ })
return creds