aboutsummaryrefslogtreecommitdiffstats
path: root/functest/utils
diff options
context:
space:
mode:
Diffstat (limited to 'functest/utils')
-rw-r--r--functest/utils/functest_constants.py2
-rw-r--r--functest/utils/functest_utils.py5
-rwxr-xr-xfunctest/utils/openstack_clean.py8
-rwxr-xr-xfunctest/utils/openstack_snapshot.py2
-rwxr-xr-xfunctest/utils/openstack_utils.py56
5 files changed, 48 insertions, 25 deletions
diff --git a/functest/utils/functest_constants.py b/functest/utils/functest_constants.py
index e25d6e02..ac9d77c8 100644
--- a/functest/utils/functest_constants.py
+++ b/functest/utils/functest_constants.py
@@ -103,7 +103,7 @@ 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.dir.dir_rally',
+RALLY_RELATIVE_PATH = get_value('general.dir.rally',
'RALLY_RELATIVE_PATH')
RALLY_PRIVATE_NET_NAME = get_value('rally.network_name',
'RALLY_PRIVATE_NET_NAME')
diff --git a/functest/utils/functest_utils.py b/functest/utils/functest_utils.py
index 3145f573..1879e694 100644
--- a/functest/utils/functest_utils.py
+++ b/functest/utils/functest_utils.py
@@ -7,12 +7,14 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
#
+import functools
import json
import os
import re
import shutil
import subprocess
import sys
+import time
import urllib2
from datetime import datetime as dt
@@ -21,9 +23,6 @@ import requests
import yaml
from git import Repo
-import time
-import functools
-
import functest.utils.functest_logger as ft_logger
logger = ft_logger.Logger("functest_utils").getLogger()
diff --git a/functest/utils/openstack_clean.py b/functest/utils/openstack_clean.py
index b1ad9664..15a8f33d 100755
--- a/functest/utils/openstack_clean.py
+++ b/functest/utils/openstack_clean.py
@@ -397,7 +397,7 @@ def main():
default_security_groups = snapshot_yaml.get('secgroups')
default_floatingips = snapshot_yaml.get('floatingips')
default_users = snapshot_yaml.get('users')
- # default_tenants = snapshot_yaml.get('tenants')
+ default_tenants = snapshot_yaml.get('tenants')
if not os_utils.check_credentials():
logger.error("Please source the openrc credentials and run "
@@ -418,10 +418,8 @@ def main():
separator()
remove_users(keystone_client, default_users)
separator()
- # TODO (Helen) tenant does not exist in V3
- # need to figure our anohter general verification point
- # remove_tenants(keystone_client, default_tenants)
- # separator()
+ remove_tenants(keystone_client, default_tenants)
+ separator()
if __name__ == '__main__':
diff --git a/functest/utils/openstack_snapshot.py b/functest/utils/openstack_snapshot.py
index c59492cf..e64030f7 100755
--- a/functest/utils/openstack_snapshot.py
+++ b/functest/utils/openstack_snapshot.py
@@ -150,7 +150,7 @@ def main():
snapshot.update(get_security_groups(neutron_client))
snapshot.update(get_floatinips(nova_client))
snapshot.update(get_users(keystone_client))
- # snapshot.update(get_tenants(keystone_client))
+ snapshot.update(get_tenants(keystone_client))
with open(OS_SNAPSHOT_FILE, 'w+') as yaml_file:
yaml_file.write(yaml.safe_dump(snapshot, default_flow_style=False))
diff --git a/functest/utils/openstack_utils.py b/functest/utils/openstack_utils.py
index 38a30cb3..64f18504 100755
--- a/functest/utils/openstack_utils.py
+++ b/functest/utils/openstack_utils.py
@@ -52,14 +52,13 @@ def is_keystone_v3():
def get_rc_env_vars():
- keystone_v3 = is_keystone_v3()
env_vars = ['OS_AUTH_URL', 'OS_USERNAME', 'OS_PASSWORD']
- if keystone_v3 is False:
- env_vars.extend(['OS_TENANT_NAME'])
- else:
+ if is_keystone_v3():
env_vars.extend(['OS_PROJECT_NAME',
'OS_USER_DOMAIN_NAME',
'OS_PROJECT_DOMAIN_NAME'])
+ else:
+ env_vars.extend(['OS_TENANT_NAME'])
return env_vars
@@ -1254,7 +1253,10 @@ def delete_volume_type(cinder_client, volume_type):
# *********************************************
def get_tenants(keystone_client):
try:
- tenants = keystone_client.tenants.list()
+ if is_keystone_v3():
+ tenants = keystone_client.projects.list()
+ else:
+ tenants = keystone_client.tenants.list()
return tenants
except Exception, e:
logger.error("Error [get_tenants(keystone_client)]: %s" % e)
@@ -1271,7 +1273,7 @@ def get_users(keystone_client):
def get_tenant_id(keystone_client, tenant_name):
- tenants = keystone_client.tenants.list()
+ tenants = get_tenants(keystone_client)
id = ''
for t in tenants:
if t.name == tenant_name:
@@ -1281,7 +1283,7 @@ def get_tenant_id(keystone_client, tenant_name):
def get_user_id(keystone_client, user_name):
- users = keystone_client.users.list()
+ users = get_users(keystone_client)
id = ''
for u in users:
if u.name == user_name:
@@ -1302,9 +1304,16 @@ def get_role_id(keystone_client, role_name):
def create_tenant(keystone_client, tenant_name, tenant_description):
try:
- tenant = keystone_client.tenants.create(tenant_name,
- tenant_description,
- enabled=True)
+ if is_keystone_v3():
+ tenant = keystone_client.projects.create(
+ name=tenant_name,
+ description=tenant_description,
+ domain="default",
+ enabled=True)
+ else:
+ tenant = keystone_client.tenants.create(tenant_name,
+ tenant_description,
+ enabled=True)
return tenant.id
except Exception, e:
logger.error("Error [create_tenant(keystone_client, '%s', '%s')]: %s"
@@ -1315,9 +1324,18 @@ def create_tenant(keystone_client, tenant_name, tenant_description):
def create_user(keystone_client, user_name, user_password,
user_email, tenant_id):
try:
- user = keystone_client.users.create(user_name, user_password,
- user_email, tenant_id,
- enabled=True)
+ if is_keystone_v3():
+ user = keystone_client.users.create(name=user_name,
+ password=user_password,
+ email=user_email,
+ project_id=tenant_id,
+ enabled=True)
+ else:
+ user = keystone_client.users.create(user_name,
+ user_password,
+ user_email,
+ tenant_id,
+ enabled=True)
return user.id
except Exception, e:
logger.error("Error [create_user(keystone_client, '%s', '%s', '%s'"
@@ -1328,7 +1346,12 @@ def create_user(keystone_client, user_name, user_password,
def add_role_user(keystone_client, user_id, role_id, tenant_id):
try:
- keystone_client.roles.add_user_role(user_id, role_id, tenant_id)
+ if is_keystone_v3():
+ keystone_client.roles.grant(role=role_id,
+ user=user_id,
+ project=tenant_id)
+ else:
+ keystone_client.roles.add_user_role(user_id, role_id, tenant_id)
return True
except Exception, e:
logger.error("Error [add_role_user(keystone_client, '%s', '%s'"
@@ -1338,7 +1361,10 @@ def add_role_user(keystone_client, user_id, role_id, tenant_id):
def delete_tenant(keystone_client, tenant_id):
try:
- keystone_client.tenants.delete(tenant_id)
+ if is_keystone_v3():
+ keystone_client.projects.delete(tenant_id)
+ else:
+ keystone_client.tenants.delete(tenant_id)
return True
except Exception, e:
logger.error("Error [delete_tenant(keystone_client, '%s')]: %s"