summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--snaps/openstack/utils/keystone_utils.py6
-rw-r--r--snaps/openstack/utils/tests/keystone_utils_tests.py24
2 files changed, 24 insertions, 6 deletions
diff --git a/snaps/openstack/utils/keystone_utils.py b/snaps/openstack/utils/keystone_utils.py
index f0de567..3823914 100644
--- a/snaps/openstack/utils/keystone_utils.py
+++ b/snaps/openstack/utils/keystone_utils.py
@@ -79,18 +79,18 @@ def keystone_client(os_creds):
session=keystone_session(os_creds), interface=os_creds.interface)
-def get_endpoint(os_creds, service_type, endpoint_type='publicURL'):
+def get_endpoint(os_creds, service_type, interface='public'):
"""
Returns the endpoint of specific service
:param os_creds: the OpenStack credentials (OSCreds) object
:param service_type: the type of specific service
- :param endpoint_type: the type of endpoint
+ :param interface: the type of interface
:return: the endpoint url
"""
auth = get_session_auth(os_creds)
key_session = keystone_session(os_creds)
return key_session.get_endpoint(
- auth=auth, service_type=service_type, endpoint_type=endpoint_type)
+ auth=auth, service_type=service_type, interface=interface)
def get_project(keystone=None, os_creds=None, project_name=None):
diff --git a/snaps/openstack/utils/tests/keystone_utils_tests.py b/snaps/openstack/utils/tests/keystone_utils_tests.py
index d9ff3ed..1fc9d38 100644
--- a/snaps/openstack/utils/tests/keystone_utils_tests.py
+++ b/snaps/openstack/utils/tests/keystone_utils_tests.py
@@ -110,7 +110,7 @@ class KeystoneUtilsTests(OSComponentTestCase):
succeed.
"""
endpoint = keystone_utils.get_endpoint(self.os_creds,
- service_type="identity")
+ service_type='identity')
self.assertIsNotNone(endpoint)
def test_get_endpoint_fail_without_proper_service(self):
@@ -119,7 +119,7 @@ class KeystoneUtilsTests(OSComponentTestCase):
cannot succeed.
"""
with self.assertRaises(Exception):
- keystone_utils.get_endpoint(self.os_creds, service_type="glance")
+ keystone_utils.get_endpoint(self.os_creds, service_type='glance')
def test_get_endpoint_fail_without_proper_credentials(self):
"""
@@ -132,4 +132,22 @@ class KeystoneUtilsTests(OSComponentTestCase):
keystone_utils.get_endpoint(
OSCreds(username='user', password='pass', auth_url='url',
project_name='project'),
- service_type="image")
+ service_type='image')
+
+ def test_get_endpoint_with_different_interface(self):
+ """
+ Tests to ensure that different endpoint urls are obtained with
+ 'public', 'internal' and 'admin' interface
+ """
+ endpoint_public = keystone_utils.get_endpoint(self.os_creds,
+ service_type='image',
+ interface='public')
+ endpoint_internal = keystone_utils.get_endpoint(self.os_creds,
+ service_type='image',
+ interface='internal')
+ endpoint_admin = keystone_utils.get_endpoint(self.os_creds,
+ service_type='image',
+ interface='admin')
+ self.assertNotEqual(endpoint_public, endpoint_internal)
+ self.assertNotEqual(endpoint_public, endpoint_admin)
+ self.assertEqual(endpoint_admin, endpoint_internal)