Replace endpoint_type with interface in catalog
We've been trying to move people onto using interface rather than endpoint_type for a while as interface is what is talked about in all the API docs and is what is exposed by the clients. Rename all occurrences of endpoint_type with interface. Change-Id: If18d8e27e499c294cb4dc94521da843341287362
This commit is contained in:
parent
65cbe5012d
commit
d227f6d237
@ -35,28 +35,28 @@ class ServiceCatalog(object):
|
|||||||
return endpoint.get('region_id') or endpoint.get('region')
|
return endpoint.get('region_id') or endpoint.get('region')
|
||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
def is_endpoint_type_match(self, endpoint, endpoint_type):
|
def is_interface_match(self, endpoint, interface):
|
||||||
"""Helper function to normalize endpoint matching across v2 and v3.
|
"""Helper function to normalize endpoint matching across v2 and v3.
|
||||||
|
|
||||||
:returns: True if the provided endpoint matches the required
|
:returns: True if the provided endpoint matches the required
|
||||||
endpoint_type otherwise False.
|
interface otherwise False.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def normalize_endpoint_type(self, endpoint_type):
|
def normalize_interface(self, interface):
|
||||||
"""Handle differences in the way v2 and v3 catalogs specify endpoint.
|
"""Handle differences in the way v2 and v3 catalogs specify endpoint.
|
||||||
|
|
||||||
Both v2 and v3 must be able to handle the endpoint style of the other.
|
Both v2 and v3 must be able to handle the endpoint style of the other.
|
||||||
For example v2 must be able to handle a 'public' endpoint_type and
|
For example v2 must be able to handle a 'public' interface and
|
||||||
v3 must be able to handle a 'publicURL' endpoint_type.
|
v3 must be able to handle a 'publicURL' interface.
|
||||||
|
|
||||||
:returns: the endpoint string in the format appropriate for this
|
:returns: the endpoint string in the format appropriate for this
|
||||||
service catalog.
|
service catalog.
|
||||||
"""
|
"""
|
||||||
return endpoint_type
|
return interface
|
||||||
|
|
||||||
@utils.positional()
|
@utils.positional()
|
||||||
def get_endpoints(self, service_type=None, endpoint_type=None,
|
def get_endpoints(self, service_type=None, interface=None,
|
||||||
region_name=None, service_name=None,
|
region_name=None, service_name=None,
|
||||||
service_id=None, endpoint_id=None):
|
service_id=None, endpoint_id=None):
|
||||||
"""Fetch and filter endpoints for the specified service(s).
|
"""Fetch and filter endpoints for the specified service(s).
|
||||||
@ -68,7 +68,7 @@ class ServiceCatalog(object):
|
|||||||
be skipped. This allows compatibility with services that existed
|
be skipped. This allows compatibility with services that existed
|
||||||
before the name was available in the catalog.
|
before the name was available in the catalog.
|
||||||
"""
|
"""
|
||||||
endpoint_type = self.normalize_endpoint_type(endpoint_type)
|
interface = self.normalize_interface(interface)
|
||||||
|
|
||||||
sc = {}
|
sc = {}
|
||||||
|
|
||||||
@ -105,8 +105,8 @@ class ServiceCatalog(object):
|
|||||||
endpoints = sc.setdefault(st, [])
|
endpoints = sc.setdefault(st, [])
|
||||||
|
|
||||||
for endpoint in service.get('endpoints', []):
|
for endpoint in service.get('endpoints', []):
|
||||||
if (endpoint_type and not
|
if (interface and not
|
||||||
self.is_endpoint_type_match(endpoint, endpoint_type)):
|
self.is_interface_match(endpoint, interface)):
|
||||||
continue
|
continue
|
||||||
if (region_name and
|
if (region_name and
|
||||||
region_name != self._get_endpoint_region(endpoint)):
|
region_name != self._get_endpoint_region(endpoint)):
|
||||||
@ -132,7 +132,7 @@ class ServiceCatalog(object):
|
|||||||
|
|
||||||
@abc.abstractmethod
|
@abc.abstractmethod
|
||||||
@utils.positional()
|
@utils.positional()
|
||||||
def get_urls(self, service_type=None, endpoint_type='public',
|
def get_urls(self, service_type=None, interface='public',
|
||||||
region_name=None, service_name=None,
|
region_name=None, service_name=None,
|
||||||
service_id=None, endpoint_id=None):
|
service_id=None, endpoint_id=None):
|
||||||
"""Fetch endpoint urls from the service catalog.
|
"""Fetch endpoint urls from the service catalog.
|
||||||
@ -142,7 +142,7 @@ class ServiceCatalog(object):
|
|||||||
endpoint of the specified type.
|
endpoint of the specified type.
|
||||||
|
|
||||||
:param string service_type: Service type of the endpoint.
|
:param string service_type: Service type of the endpoint.
|
||||||
:param string endpoint_type: Type of endpoint.
|
:param string interface: Type of endpoint.
|
||||||
Possible values: public or publicURL,
|
Possible values: public or publicURL,
|
||||||
internal or internalURL, admin or
|
internal or internalURL, admin or
|
||||||
adminURL
|
adminURL
|
||||||
@ -156,7 +156,7 @@ class ServiceCatalog(object):
|
|||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
@utils.positional()
|
@utils.positional()
|
||||||
def url_for(self, service_type=None, endpoint_type='public',
|
def url_for(self, service_type=None, interface='public',
|
||||||
region_name=None, service_name=None,
|
region_name=None, service_name=None,
|
||||||
service_id=None, endpoint_id=None):
|
service_id=None, endpoint_id=None):
|
||||||
"""Fetch an endpoint from the service catalog.
|
"""Fetch an endpoint from the service catalog.
|
||||||
@ -170,7 +170,7 @@ class ServiceCatalog(object):
|
|||||||
`admin` or 'adminURL`
|
`admin` or 'adminURL`
|
||||||
|
|
||||||
:param string service_type: Service type of the endpoint.
|
:param string service_type: Service type of the endpoint.
|
||||||
:param string endpoint_type: Type of endpoint.
|
:param string interface: Type of endpoint.
|
||||||
:param string region_name: Region of the endpoint.
|
:param string region_name: Region of the endpoint.
|
||||||
:param string service_name: The assigned name of the service.
|
:param string service_name: The assigned name of the service.
|
||||||
:param string service_id: The identifier of a service.
|
:param string service_id: The identifier of a service.
|
||||||
@ -180,7 +180,7 @@ class ServiceCatalog(object):
|
|||||||
raise exceptions.EmptyCatalog('The service catalog is empty.')
|
raise exceptions.EmptyCatalog('The service catalog is empty.')
|
||||||
|
|
||||||
urls = self.get_urls(service_type=service_type,
|
urls = self.get_urls(service_type=service_type,
|
||||||
endpoint_type=endpoint_type,
|
interface=interface,
|
||||||
region_name=region_name,
|
region_name=region_name,
|
||||||
service_name=service_name,
|
service_name=service_name,
|
||||||
service_id=service_id,
|
service_id=service_id,
|
||||||
@ -192,27 +192,27 @@ class ServiceCatalog(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
if service_name and region_name:
|
if service_name and region_name:
|
||||||
msg = ('%(endpoint_type)s endpoint for %(service_type)s service '
|
msg = ('%(interface)s endpoint for %(service_type)s service '
|
||||||
'named %(service_name)s in %(region_name)s region not '
|
'named %(service_name)s in %(region_name)s region not '
|
||||||
'found' %
|
'found' %
|
||||||
{'endpoint_type': endpoint_type,
|
{'interface': interface,
|
||||||
'service_type': service_type, 'service_name': service_name,
|
'service_type': service_type, 'service_name': service_name,
|
||||||
'region_name': region_name})
|
'region_name': region_name})
|
||||||
elif service_name:
|
elif service_name:
|
||||||
msg = ('%(endpoint_type)s endpoint for %(service_type)s service '
|
msg = ('%(interface)s endpoint for %(service_type)s service '
|
||||||
'named %(service_name)s not found' %
|
'named %(service_name)s not found' %
|
||||||
{'endpoint_type': endpoint_type,
|
{'interface': interface,
|
||||||
'service_type': service_type,
|
'service_type': service_type,
|
||||||
'service_name': service_name})
|
'service_name': service_name})
|
||||||
elif region_name:
|
elif region_name:
|
||||||
msg = ('%(endpoint_type)s endpoint for %(service_type)s service '
|
msg = ('%(interface)s endpoint for %(service_type)s service '
|
||||||
'in %(region_name)s region not found' %
|
'in %(region_name)s region not found' %
|
||||||
{'endpoint_type': endpoint_type,
|
{'interface': interface,
|
||||||
'service_type': service_type, 'region_name': region_name})
|
'service_type': service_type, 'region_name': region_name})
|
||||||
else:
|
else:
|
||||||
msg = ('%(endpoint_type)s endpoint for %(service_type)s service '
|
msg = ('%(interface)s endpoint for %(service_type)s service '
|
||||||
'not found' %
|
'not found' %
|
||||||
{'endpoint_type': endpoint_type,
|
{'interface': interface,
|
||||||
'service_type': service_type})
|
'service_type': service_type})
|
||||||
|
|
||||||
raise exceptions.EndpointNotFound(msg)
|
raise exceptions.EndpointNotFound(msg)
|
||||||
@ -231,29 +231,29 @@ class ServiceCatalogV2(ServiceCatalog):
|
|||||||
return cls(token['access'].get('serviceCatalog', {}))
|
return cls(token['access'].get('serviceCatalog', {}))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def normalize_endpoint_type(endpoint_type):
|
def normalize_interface(interface):
|
||||||
if endpoint_type and 'URL' not in endpoint_type:
|
if interface and 'URL' not in interface:
|
||||||
endpoint_type = endpoint_type + 'URL'
|
interface = interface + 'URL'
|
||||||
|
|
||||||
return endpoint_type
|
return interface
|
||||||
|
|
||||||
def is_endpoint_type_match(self, endpoint, endpoint_type):
|
def is_interface_match(self, endpoint, interface):
|
||||||
return endpoint_type in endpoint
|
return interface in endpoint
|
||||||
|
|
||||||
@utils.positional()
|
@utils.positional()
|
||||||
def get_urls(self, service_type=None, endpoint_type='publicURL',
|
def get_urls(self, service_type=None, interface='publicURL',
|
||||||
region_name=None, service_name=None,
|
region_name=None, service_name=None,
|
||||||
service_id=None, endpoint_id=None):
|
service_id=None, endpoint_id=None):
|
||||||
endpoint_type = self.normalize_endpoint_type(endpoint_type)
|
interface = self.normalize_interface(interface)
|
||||||
|
|
||||||
endpoints = self._get_service_endpoints(service_type=service_type,
|
endpoints = self._get_service_endpoints(service_type=service_type,
|
||||||
endpoint_type=endpoint_type,
|
interface=interface,
|
||||||
region_name=region_name,
|
region_name=region_name,
|
||||||
service_name=service_name,
|
service_name=service_name,
|
||||||
service_id=service_id,
|
service_id=service_id,
|
||||||
endpoint_id=endpoint_id)
|
endpoint_id=endpoint_id)
|
||||||
|
|
||||||
return tuple([endpoint[endpoint_type] for endpoint in endpoints])
|
return tuple([endpoint[interface] for endpoint in endpoints])
|
||||||
|
|
||||||
|
|
||||||
class ServiceCatalogV3(ServiceCatalog):
|
class ServiceCatalogV3(ServiceCatalog):
|
||||||
@ -269,24 +269,24 @@ class ServiceCatalogV3(ServiceCatalog):
|
|||||||
return cls(token['token'].get('catalog', {}))
|
return cls(token['token'].get('catalog', {}))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def normalize_endpoint_type(endpoint_type):
|
def normalize_interface(interface):
|
||||||
if endpoint_type:
|
if interface:
|
||||||
endpoint_type = endpoint_type.rstrip('URL')
|
interface = interface.rstrip('URL')
|
||||||
|
|
||||||
return endpoint_type
|
return interface
|
||||||
|
|
||||||
def is_endpoint_type_match(self, endpoint, endpoint_type):
|
def is_interface_match(self, endpoint, interface):
|
||||||
try:
|
try:
|
||||||
return endpoint_type == endpoint['interface']
|
return interface == endpoint['interface']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@utils.positional()
|
@utils.positional()
|
||||||
def get_urls(self, service_type=None, endpoint_type='publicURL',
|
def get_urls(self, service_type=None, interface='publicURL',
|
||||||
region_name=None, service_name=None,
|
region_name=None, service_name=None,
|
||||||
service_id=None, endpoint_id=None):
|
service_id=None, endpoint_id=None):
|
||||||
endpoints = self._get_service_endpoints(service_type=service_type,
|
endpoints = self._get_service_endpoints(service_type=service_type,
|
||||||
endpoint_type=endpoint_type,
|
interface=interface,
|
||||||
region_name=region_name,
|
region_name=region_name,
|
||||||
service_name=service_name,
|
service_name=service_name,
|
||||||
service_id=service_id,
|
service_id=service_id,
|
||||||
|
@ -217,7 +217,7 @@ class BaseIdentityPlugin(base.BaseAuthPlugin):
|
|||||||
|
|
||||||
service_catalog = self.get_access(session).service_catalog
|
service_catalog = self.get_access(session).service_catalog
|
||||||
url = service_catalog.url_for(service_type=service_type,
|
url = service_catalog.url_for(service_type=service_type,
|
||||||
endpoint_type=interface,
|
interface=interface,
|
||||||
region_name=region_name,
|
region_name=region_name,
|
||||||
service_name=service_name)
|
service_name=service_name)
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ class ServiceCatalogTest(utils.TestCase):
|
|||||||
auth_ref = access.create(body=self.AUTH_RESPONSE_BODY)
|
auth_ref = access.create(body=self.AUTH_RESPONSE_BODY)
|
||||||
sc = auth_ref.service_catalog
|
sc = auth_ref.service_catalog
|
||||||
public_ep = sc.get_endpoints(service_type='compute',
|
public_ep = sc.get_endpoints(service_type='compute',
|
||||||
endpoint_type='publicURL')
|
interface='publicURL')
|
||||||
self.assertEqual(public_ep['compute'][1]['tenantId'], '2')
|
self.assertEqual(public_ep['compute'][1]['tenantId'], '2')
|
||||||
self.assertEqual(public_ep['compute'][1]['versionId'], '1.1')
|
self.assertEqual(public_ep['compute'][1]['versionId'], '1.1')
|
||||||
self.assertEqual(public_ep['compute'][1]['internalURL'],
|
self.assertEqual(public_ep['compute'][1]['internalURL'],
|
||||||
@ -108,7 +108,7 @@ class ServiceCatalogTest(utils.TestCase):
|
|||||||
self.assertRaises(exceptions.EmptyCatalog,
|
self.assertRaises(exceptions.EmptyCatalog,
|
||||||
auth_ref.service_catalog.url_for,
|
auth_ref.service_catalog.url_for,
|
||||||
service_type='image',
|
service_type='image',
|
||||||
endpoint_type='internalURL')
|
interface='internalURL')
|
||||||
|
|
||||||
def test_service_catalog_get_endpoints_region_names(self):
|
def test_service_catalog_get_endpoints_region_names(self):
|
||||||
auth_ref = access.create(body=self.AUTH_RESPONSE_BODY)
|
auth_ref = access.create(body=self.AUTH_RESPONSE_BODY)
|
||||||
@ -170,7 +170,7 @@ class ServiceCatalogTest(utils.TestCase):
|
|||||||
auth_ref = access.create(body=self.AUTH_RESPONSE_BODY)
|
auth_ref = access.create(body=self.AUTH_RESPONSE_BODY)
|
||||||
sc = auth_ref.service_catalog
|
sc = auth_ref.service_catalog
|
||||||
|
|
||||||
url = sc.url_for(service_name='Image Servers', endpoint_type='public',
|
url = sc.url_for(service_name='Image Servers', interface='public',
|
||||||
service_type='image', region_name='North')
|
service_type='image', region_name='North')
|
||||||
self.assertEqual('https://image.north.host/v1/', url)
|
self.assertEqual('https://image.north.host/v1/', url)
|
||||||
|
|
||||||
@ -178,13 +178,13 @@ class ServiceCatalogTest(utils.TestCase):
|
|||||||
service_name='Image Servers', service_type='compute')
|
service_name='Image Servers', service_type='compute')
|
||||||
|
|
||||||
urls = sc.get_urls(service_type='image', service_name='Image Servers',
|
urls = sc.get_urls(service_type='image', service_name='Image Servers',
|
||||||
endpoint_type='public')
|
interface='public')
|
||||||
|
|
||||||
self.assertIn('https://image.north.host/v1/', urls)
|
self.assertIn('https://image.north.host/v1/', urls)
|
||||||
self.assertIn('https://image.south.host/v1/', urls)
|
self.assertIn('https://image.south.host/v1/', urls)
|
||||||
|
|
||||||
urls = sc.get_urls(service_type='image', service_name='Servers',
|
urls = sc.get_urls(service_type='image', service_name='Servers',
|
||||||
endpoint_type='public')
|
interface='public')
|
||||||
|
|
||||||
self.assertEqual(0, len(urls))
|
self.assertEqual(0, len(urls))
|
||||||
|
|
||||||
@ -202,12 +202,12 @@ class ServiceCatalogTest(utils.TestCase):
|
|||||||
auth_ref = access.create(body=token)
|
auth_ref = access.create(body=token)
|
||||||
|
|
||||||
urls = auth_ref.service_catalog.get_urls(service_type='compute',
|
urls = auth_ref.service_catalog.get_urls(service_type='compute',
|
||||||
endpoint_type='publicURL')
|
interface='publicURL')
|
||||||
|
|
||||||
self.assertEqual(set(['public-0', 'public-1', 'public-2']), set(urls))
|
self.assertEqual(set(['public-0', 'public-1', 'public-2']), set(urls))
|
||||||
|
|
||||||
urls = auth_ref.service_catalog.get_urls(service_type='compute',
|
urls = auth_ref.service_catalog.get_urls(service_type='compute',
|
||||||
endpoint_type='publicURL',
|
interface='publicURL',
|
||||||
region_name='region-1')
|
region_name='region-1')
|
||||||
|
|
||||||
self.assertEqual(('public-1', ), urls)
|
self.assertEqual(('public-1', ), urls)
|
||||||
@ -225,24 +225,24 @@ class ServiceCatalogTest(utils.TestCase):
|
|||||||
auth_ref = access.create(body=token)
|
auth_ref = access.create(body=token)
|
||||||
|
|
||||||
# initially assert that we get back all our urls for a simple filter
|
# initially assert that we get back all our urls for a simple filter
|
||||||
urls = auth_ref.service_catalog.get_urls(endpoint_type='public')
|
urls = auth_ref.service_catalog.get_urls(interface='public')
|
||||||
self.assertEqual(2, len(urls))
|
self.assertEqual(2, len(urls))
|
||||||
|
|
||||||
urls = auth_ref.service_catalog.get_urls(endpoint_id=endpoint_id,
|
urls = auth_ref.service_catalog.get_urls(endpoint_id=endpoint_id,
|
||||||
endpoint_type='public')
|
interface='public')
|
||||||
|
|
||||||
self.assertEqual((public_url, ), urls)
|
self.assertEqual((public_url, ), urls)
|
||||||
|
|
||||||
# with bad endpoint_id nothing should be found
|
# with bad endpoint_id nothing should be found
|
||||||
urls = auth_ref.service_catalog.get_urls(endpoint_id=uuid.uuid4().hex,
|
urls = auth_ref.service_catalog.get_urls(endpoint_id=uuid.uuid4().hex,
|
||||||
endpoint_type='public')
|
interface='public')
|
||||||
|
|
||||||
self.assertEqual(0, len(urls))
|
self.assertEqual(0, len(urls))
|
||||||
|
|
||||||
# we ignore a service_id because v2 doesn't know what it is
|
# we ignore a service_id because v2 doesn't know what it is
|
||||||
urls = auth_ref.service_catalog.get_urls(endpoint_id=endpoint_id,
|
urls = auth_ref.service_catalog.get_urls(endpoint_id=endpoint_id,
|
||||||
service_id=uuid.uuid4().hex,
|
service_id=uuid.uuid4().hex,
|
||||||
endpoint_type='public')
|
interface='public')
|
||||||
|
|
||||||
self.assertEqual((public_url, ), urls)
|
self.assertEqual((public_url, ), urls)
|
||||||
|
|
||||||
@ -261,7 +261,7 @@ class ServiceCatalogTest(utils.TestCase):
|
|||||||
|
|
||||||
auth_ref = access.create(body=token)
|
auth_ref = access.create(body=token)
|
||||||
urls = auth_ref.service_catalog.get_urls(service_type=None,
|
urls = auth_ref.service_catalog.get_urls(service_type=None,
|
||||||
endpoint_type='public')
|
interface='public')
|
||||||
|
|
||||||
self.assertEqual(3, len(urls))
|
self.assertEqual(3, len(urls))
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ class ServiceCatalogTest(utils.TestCase):
|
|||||||
self.assertEqual(sc.url_for(service_type='compute'),
|
self.assertEqual(sc.url_for(service_type='compute'),
|
||||||
"https://compute.north.host/novapi/public")
|
"https://compute.north.host/novapi/public")
|
||||||
self.assertEqual(sc.url_for(service_type='compute',
|
self.assertEqual(sc.url_for(service_type='compute',
|
||||||
endpoint_type='internal'),
|
interface='internal'),
|
||||||
"https://compute.north.host/novapi/internal")
|
"https://compute.north.host/novapi/internal")
|
||||||
|
|
||||||
self.assertRaises(exceptions.EndpointNotFound,
|
self.assertRaises(exceptions.EndpointNotFound,
|
||||||
@ -92,7 +92,7 @@ class ServiceCatalogTest(utils.TestCase):
|
|||||||
sc = auth_ref.service_catalog
|
sc = auth_ref.service_catalog
|
||||||
|
|
||||||
public_ep = sc.get_endpoints(service_type='compute',
|
public_ep = sc.get_endpoints(service_type='compute',
|
||||||
endpoint_type='public')
|
interface='public')
|
||||||
self.assertEqual(public_ep['compute'][0]['region'], 'North')
|
self.assertEqual(public_ep['compute'][0]['region'], 'North')
|
||||||
self.assertEqual(public_ep['compute'][0]['url'],
|
self.assertEqual(public_ep['compute'][0]['url'],
|
||||||
"https://compute.north.host/novapi/public")
|
"https://compute.north.host/novapi/public")
|
||||||
@ -103,7 +103,7 @@ class ServiceCatalogTest(utils.TestCase):
|
|||||||
body=self.AUTH_RESPONSE_BODY)
|
body=self.AUTH_RESPONSE_BODY)
|
||||||
sc = auth_ref.service_catalog
|
sc = auth_ref.service_catalog
|
||||||
|
|
||||||
url = sc.url_for(service_type='image', endpoint_type='public')
|
url = sc.url_for(service_type='image', interface='public')
|
||||||
self.assertEqual(url, "http://glance.north.host/glanceapi/public")
|
self.assertEqual(url, "http://glance.north.host/glanceapi/public")
|
||||||
|
|
||||||
self.AUTH_RESPONSE_BODY['token']['region_name'] = "South"
|
self.AUTH_RESPONSE_BODY['token']['region_name'] = "South"
|
||||||
@ -112,7 +112,7 @@ class ServiceCatalogTest(utils.TestCase):
|
|||||||
sc = auth_ref.service_catalog
|
sc = auth_ref.service_catalog
|
||||||
url = sc.url_for(service_type='image',
|
url = sc.url_for(service_type='image',
|
||||||
region_name="South",
|
region_name="South",
|
||||||
endpoint_type='internal')
|
interface='internal')
|
||||||
self.assertEqual(url, "http://glance.south.host/glanceapi/internal")
|
self.assertEqual(url, "http://glance.south.host/glanceapi/internal")
|
||||||
|
|
||||||
def test_service_catalog_empty(self):
|
def test_service_catalog_empty(self):
|
||||||
@ -122,7 +122,7 @@ class ServiceCatalogTest(utils.TestCase):
|
|||||||
self.assertRaises(exceptions.EmptyCatalog,
|
self.assertRaises(exceptions.EmptyCatalog,
|
||||||
auth_ref.service_catalog.url_for,
|
auth_ref.service_catalog.url_for,
|
||||||
service_type='image',
|
service_type='image',
|
||||||
endpoint_type='internalURL')
|
interface='internalURL')
|
||||||
|
|
||||||
def test_service_catalog_get_endpoints_region_names(self):
|
def test_service_catalog_get_endpoints_region_names(self):
|
||||||
sc = access.create(auth_token=uuid.uuid4().hex,
|
sc = access.create(auth_token=uuid.uuid4().hex,
|
||||||
@ -186,11 +186,11 @@ class ServiceCatalogTest(utils.TestCase):
|
|||||||
sc = access.create(auth_token=uuid.uuid4().hex,
|
sc = access.create(auth_token=uuid.uuid4().hex,
|
||||||
body=self.AUTH_RESPONSE_BODY).service_catalog
|
body=self.AUTH_RESPONSE_BODY).service_catalog
|
||||||
|
|
||||||
url = sc.url_for(service_name='glance', endpoint_type='public',
|
url = sc.url_for(service_name='glance', interface='public',
|
||||||
service_type='image', region_name='North')
|
service_type='image', region_name='North')
|
||||||
self.assertEqual('http://glance.north.host/glanceapi/public', url)
|
self.assertEqual('http://glance.north.host/glanceapi/public', url)
|
||||||
|
|
||||||
url = sc.url_for(service_name='glance', endpoint_type='public',
|
url = sc.url_for(service_name='glance', interface='public',
|
||||||
service_type='image', region_name='South')
|
service_type='image', region_name='South')
|
||||||
self.assertEqual('http://glance.south.host/glanceapi/public', url)
|
self.assertEqual('http://glance.south.host/glanceapi/public', url)
|
||||||
|
|
||||||
@ -198,14 +198,14 @@ class ServiceCatalogTest(utils.TestCase):
|
|||||||
service_name='glance', service_type='compute')
|
service_name='glance', service_type='compute')
|
||||||
|
|
||||||
urls = sc.get_urls(service_type='image', service_name='glance',
|
urls = sc.get_urls(service_type='image', service_name='glance',
|
||||||
endpoint_type='public')
|
interface='public')
|
||||||
|
|
||||||
self.assertIn('http://glance.north.host/glanceapi/public', urls)
|
self.assertIn('http://glance.north.host/glanceapi/public', urls)
|
||||||
self.assertIn('http://glance.south.host/glanceapi/public', urls)
|
self.assertIn('http://glance.south.host/glanceapi/public', urls)
|
||||||
|
|
||||||
urls = sc.get_urls(service_type='image',
|
urls = sc.get_urls(service_type='image',
|
||||||
service_name='Servers',
|
service_name='Servers',
|
||||||
endpoint_type='public')
|
interface='public')
|
||||||
|
|
||||||
self.assertEqual(0, len(urls))
|
self.assertEqual(0, len(urls))
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ class ServiceCatalogTest(utils.TestCase):
|
|||||||
# this will work because there are no service names on that token
|
# this will work because there are no service names on that token
|
||||||
url_ref = 'http://public.com:8774/v2/225da22d3ce34b15877ea70b2a575f58'
|
url_ref = 'http://public.com:8774/v2/225da22d3ce34b15877ea70b2a575f58'
|
||||||
url = pr_sc.url_for(service_type='compute', service_name='NotExist',
|
url = pr_sc.url_for(service_type='compute', service_name='NotExist',
|
||||||
endpoint_type='public')
|
interface='public')
|
||||||
self.assertEqual(url_ref, url)
|
self.assertEqual(url_ref, url)
|
||||||
|
|
||||||
ab_auth_ref = access.create(body=self.AUTH_RESPONSE_BODY)
|
ab_auth_ref = access.create(body=self.AUTH_RESPONSE_BODY)
|
||||||
@ -269,7 +269,7 @@ class ServiceCatalogTest(utils.TestCase):
|
|||||||
# this won't work because there is a name and it's not this one
|
# this won't work because there is a name and it's not this one
|
||||||
self.assertRaises(exceptions.EndpointNotFound, ab_sc.url_for,
|
self.assertRaises(exceptions.EndpointNotFound, ab_sc.url_for,
|
||||||
service_type='compute', service_name='NotExist',
|
service_type='compute', service_name='NotExist',
|
||||||
endpoint_type='public')
|
interface='public')
|
||||||
|
|
||||||
|
|
||||||
class ServiceCatalogV3Test(ServiceCatalogTest):
|
class ServiceCatalogV3Test(ServiceCatalogTest):
|
||||||
@ -281,7 +281,7 @@ class ServiceCatalogV3Test(ServiceCatalogTest):
|
|||||||
self.assertEqual(sc.url_for(service_type='compute'),
|
self.assertEqual(sc.url_for(service_type='compute'),
|
||||||
'https://compute.north.host/novapi/public')
|
'https://compute.north.host/novapi/public')
|
||||||
self.assertEqual(sc.url_for(service_type='compute',
|
self.assertEqual(sc.url_for(service_type='compute',
|
||||||
endpoint_type='internal'),
|
interface='internal'),
|
||||||
'https://compute.north.host/novapi/internal')
|
'https://compute.north.host/novapi/internal')
|
||||||
|
|
||||||
self.assertRaises(exceptions.EndpointNotFound,
|
self.assertRaises(exceptions.EndpointNotFound,
|
||||||
@ -294,7 +294,7 @@ class ServiceCatalogV3Test(ServiceCatalogTest):
|
|||||||
body=self.AUTH_RESPONSE_BODY).service_catalog
|
body=self.AUTH_RESPONSE_BODY).service_catalog
|
||||||
|
|
||||||
public_ep = sc.get_endpoints(service_type='compute',
|
public_ep = sc.get_endpoints(service_type='compute',
|
||||||
endpoint_type='public')
|
interface='public')
|
||||||
self.assertEqual(public_ep['compute'][0]['region_id'], 'North')
|
self.assertEqual(public_ep['compute'][0]['region_id'], 'North')
|
||||||
self.assertEqual(public_ep['compute'][0]['url'],
|
self.assertEqual(public_ep['compute'][0]['url'],
|
||||||
'https://compute.north.host/novapi/public')
|
'https://compute.north.host/novapi/public')
|
||||||
@ -313,12 +313,12 @@ class ServiceCatalogV3Test(ServiceCatalogTest):
|
|||||||
auth_ref = access.create(resp=None, body=token)
|
auth_ref = access.create(resp=None, body=token)
|
||||||
|
|
||||||
urls = auth_ref.service_catalog.get_urls(service_type='compute',
|
urls = auth_ref.service_catalog.get_urls(service_type='compute',
|
||||||
endpoint_type='public')
|
interface='public')
|
||||||
|
|
||||||
self.assertEqual(set(['public-0', 'public-1', 'public-2']), set(urls))
|
self.assertEqual(set(['public-0', 'public-1', 'public-2']), set(urls))
|
||||||
|
|
||||||
urls = auth_ref.service_catalog.get_urls(service_type='compute',
|
urls = auth_ref.service_catalog.get_urls(service_type='compute',
|
||||||
endpoint_type='public',
|
interface='public',
|
||||||
region_name='region-1')
|
region_name='region-1')
|
||||||
|
|
||||||
self.assertEqual(('public-1', ), urls)
|
self.assertEqual(('public-1', ), urls)
|
||||||
@ -339,34 +339,34 @@ class ServiceCatalogV3Test(ServiceCatalogTest):
|
|||||||
|
|
||||||
# initially assert that we get back all our urls for a simple filter
|
# initially assert that we get back all our urls for a simple filter
|
||||||
urls = auth_ref.service_catalog.get_urls(service_type='compute',
|
urls = auth_ref.service_catalog.get_urls(service_type='compute',
|
||||||
endpoint_type='public')
|
interface='public')
|
||||||
self.assertEqual(2, len(urls))
|
self.assertEqual(2, len(urls))
|
||||||
|
|
||||||
# with bad endpoint_id nothing should be found
|
# with bad endpoint_id nothing should be found
|
||||||
urls = auth_ref.service_catalog.get_urls(service_type='compute',
|
urls = auth_ref.service_catalog.get_urls(service_type='compute',
|
||||||
endpoint_id=uuid.uuid4().hex,
|
endpoint_id=uuid.uuid4().hex,
|
||||||
endpoint_type='public')
|
interface='public')
|
||||||
|
|
||||||
self.assertEqual(0, len(urls))
|
self.assertEqual(0, len(urls))
|
||||||
|
|
||||||
# with service_id we get back both public endpoints
|
# with service_id we get back both public endpoints
|
||||||
urls = auth_ref.service_catalog.get_urls(service_type='compute',
|
urls = auth_ref.service_catalog.get_urls(service_type='compute',
|
||||||
service_id=service_id,
|
service_id=service_id,
|
||||||
endpoint_type='public')
|
interface='public')
|
||||||
self.assertEqual(2, len(urls))
|
self.assertEqual(2, len(urls))
|
||||||
|
|
||||||
# with service_id and endpoint_id we get back the url we want
|
# with service_id and endpoint_id we get back the url we want
|
||||||
urls = auth_ref.service_catalog.get_urls(service_type='compute',
|
urls = auth_ref.service_catalog.get_urls(service_type='compute',
|
||||||
service_id=service_id,
|
service_id=service_id,
|
||||||
endpoint_id=endpoint_id,
|
endpoint_id=endpoint_id,
|
||||||
endpoint_type='public')
|
interface='public')
|
||||||
|
|
||||||
self.assertEqual((public_url, ), urls)
|
self.assertEqual((public_url, ), urls)
|
||||||
|
|
||||||
# with service_id and endpoint_id we get back the url we want
|
# with service_id and endpoint_id we get back the url we want
|
||||||
urls = auth_ref.service_catalog.get_urls(service_type='compute',
|
urls = auth_ref.service_catalog.get_urls(service_type='compute',
|
||||||
endpoint_id=endpoint_id,
|
endpoint_id=endpoint_id,
|
||||||
endpoint_type='public')
|
interface='public')
|
||||||
|
|
||||||
self.assertEqual((public_url, ), urls)
|
self.assertEqual((public_url, ), urls)
|
||||||
|
|
||||||
@ -384,7 +384,7 @@ class ServiceCatalogV3Test(ServiceCatalogTest):
|
|||||||
s.add_endpoint('public', public_url)
|
s.add_endpoint('public', public_url)
|
||||||
|
|
||||||
auth_ref = access.create(body=token)
|
auth_ref = access.create(body=token)
|
||||||
urls = auth_ref.service_catalog.get_urls(endpoint_type='public')
|
urls = auth_ref.service_catalog.get_urls(interface='public')
|
||||||
|
|
||||||
self.assertEqual(3, len(urls))
|
self.assertEqual(3, len(urls))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user