aboutsummaryrefslogtreecommitdiffstats
path: root/functest/utils
diff options
context:
space:
mode:
authorboucherv <valentin.boucher@orange.com>2017-04-20 16:20:57 +0200
committerboucherv <valentin.boucher@orange.com>2017-04-20 18:03:13 +0200
commit0e12e2e5ac8f1ae46a1c19436675da5075ea8f44 (patch)
tree36eb524760d45080c75af995adb59faeb15a5ec6 /functest/utils
parent6dbdeb1edc2d92be2c55a1b0dfdcf1fffc05c0a7 (diff)
[VNF_base] Support existing tenant and user
Support existing tenant and user with a get_or_create_tenant method. If the tenant and user already exist it only get the id of those JIRA: FUNCTEST-799 Change-Id: Id5daf2904592e42199471bdd3547e861e6db6e32 Signed-off-by: boucherv <valentin.boucher@orange.com>
Diffstat (limited to 'functest/utils')
-rw-r--r--functest/utils/openstack_utils.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/functest/utils/openstack_utils.py b/functest/utils/openstack_utils.py
index 4663f7ba..929a761e 100644
--- a/functest/utils/openstack_utils.py
+++ b/functest/utils/openstack_utils.py
@@ -1394,6 +1394,15 @@ def create_tenant(keystone_client, tenant_name, tenant_description):
return None
+def get_or_create_tenant(keystone_client, tenant_name, tenant_description):
+ tenant_id = get_tenant_id(keystone_client, tenant_name)
+ if not tenant_id:
+ tenant_id = create_tenant(keystone_client, tenant_name,
+ tenant_description)
+
+ return tenant_id
+
+
def create_user(keystone_client, user_name, user_password,
user_email, tenant_id):
try:
@@ -1417,6 +1426,15 @@ def create_user(keystone_client, user_name, user_password,
return None
+def get_or_create_user(keystone_client, user_name, user_password,
+ tenant_id, user_email=None):
+ user_id = get_user_id(keystone_client, user_name)
+ if not user_id:
+ user_id = create_user(keystone_client, user_name, user_password,
+ user_email, tenant_id)
+ return user_id
+
+
def add_role_user(keystone_client, user_id, role_id, tenant_id):
try:
if is_keystone_v3():