aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorboucherv <valentin.boucher@orange.com>2016-07-27 14:57:58 +0200
committerJose Lausuch <jose.lausuch@ericsson.com>2016-07-28 08:40:29 +0000
commit932e23880ad613098ba518dc1fbf84e65db434a9 (patch)
tree58f5c2a998a2044da4496dacd0bcc15a5081c7b0 /utils
parent1a45b9e69357bfd6228cd862d48d709101fd40da (diff)
Add endpoint type support on functest
By default public endpoint was used but now you can use internal or admin JIRA: FUNCTEST-387 Change-Id: If1adaa88248d379ad6d74b20f2dffd76278b67b9 Signed-off-by: boucherv <valentin.boucher@orange.com>
Diffstat (limited to 'utils')
-rw-r--r--utils/openstack_utils.py37
1 files changed, 31 insertions, 6 deletions
diff --git a/utils/openstack_utils.py b/utils/openstack_utils.py
index d14828dbb..75f06046a 100644
--- a/utils/openstack_utils.py
+++ b/utils/openstack_utils.py
@@ -70,6 +70,10 @@ def get_credentials(service):
"auth_url": os.environ.get("OS_AUTH_URL"),
tenant: os.environ.get("OS_TENANT_NAME")
})
+ if os.getenv('OS_ENDPOINT_TYPE') is not None:
+ creds.update({
+ "endpoint_type": os.environ.get("OS_ENDPOINT_TYPE")
+ })
cacert = os.environ.get("OS_CACERT")
if cacert is not None:
# each openstack client uses differnt kwargs for this
@@ -94,6 +98,24 @@ def source_credentials(rc_file):
return env
+def get_credentials_for_rally():
+ creds = get_credentials("keystone")
+ admin_keys = ['username', 'tenant_name', 'password']
+ endpoint_types = [('internalURL', 'internal'),
+ ('publicURL', 'public'), ('adminURL', 'admin')]
+ if 'endpoint_type' in creds.keys():
+ for k, v in endpoint_types:
+ if creds['endpoint_type'] == k:
+ creds['endpoint_type'] = v
+ rally_conf = {"type": "ExistingCloud", "admin": {}}
+ for key in creds:
+ if key in admin_keys:
+ rally_conf['admin'][key] = creds[key]
+ else:
+ rally_conf[key] = creds[key]
+ return rally_conf
+
+
# *********************************************
# CLIENTS
# *********************************************
@@ -109,11 +131,10 @@ def get_nova_client():
def get_cinder_client():
creds_cinder = get_credentials("cinder")
- return cinderclient.Client('2', creds_cinder['username'],
- creds_cinder['api_key'],
- creds_cinder['project_id'],
- creds_cinder['auth_url'],
- service_type="volume")
+ creds_cinder.update({
+ "service_type": "volume"
+ })
+ return cinderclient.Client('2', **creds_cinder)
def get_neutron_client():
@@ -123,8 +144,12 @@ def get_neutron_client():
def get_glance_client():
keystone_client = get_keystone_client()
+ glance_endpoint_type = 'publicURL'
+ os_endpoint_type = os.getenv('OS_ENDPOINT_TYPE')
+ if os_endpoint_type is not None:
+ glance_endpoint_type = os_endpoint_type
glance_endpoint = keystone_client.service_catalog.url_for(
- service_type='image', endpoint_type='publicURL')
+ service_type='image', endpoint_type=glance_endpoint_type)
return glanceclient.Client(1, glance_endpoint,
token=keystone_client.auth_token)