summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinda Wang <wangwulin@huawei.com>2017-07-06 16:01:32 +0000
committerLinda Wang <wangwulin@huawei.com>2017-07-07 15:17:14 +0000
commite9aefb62e3e2942084b3845c08d3b0362271b852 (patch)
treee40397e6916c9f88b779c5a2e3400f744751e8a5
parent56ad05c9ed980a5e4c71d18bb4067519ae7efa49 (diff)
Fix get_endpoint
One specific service type has the same endpoint url if interface is admin or internal, while it is different from that with public interface, except the admin and internal endpoint url for service identity has same ip but different ports. Change-Id: I19c260222286d8b4aa3f0d3b7d273e192b13a96b Signed-off-by: Linda Wang <wangwulin@huawei.com>
-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)