Filter out v1.0 endpoints
- Addresses bug 1014860 - v1.0 endpoints should not be considered valid endpoints by python-novaclient - also ignores other unkown versions (for when 3 comes out) - includes updated catalog tests Change-Id: I73bd9b0dbede74ee0d975caa86145219e30262fc
This commit is contained in:
parent
a2a62a5f71
commit
ac43f6389f
@ -39,7 +39,10 @@ class ServiceCatalog(object):
|
||||
# We have a bastardized service catalog. Treat it special. :/
|
||||
for endpoint in self.catalog['endpoints']:
|
||||
if not filter_value or endpoint[attr] == filter_value:
|
||||
matching_endpoints.append(endpoint)
|
||||
# Ignore 1.0 compute endpoints
|
||||
if endpoint.get("type") == 'compute' and \
|
||||
endpoint.get('versionId') in (None, '1.1', '2'):
|
||||
matching_endpoints.append(endpoint)
|
||||
if not matching_endpoints:
|
||||
raise novaclient.exceptions.EndpointNotFound()
|
||||
|
||||
@ -64,6 +67,10 @@ class ServiceCatalog(object):
|
||||
|
||||
endpoints = service['endpoints']
|
||||
for endpoint in endpoints:
|
||||
# Ignore 1.0 compute endpoints
|
||||
if service.get("type") == 'compute' and \
|
||||
endpoint.get('versionId', '2') not in ('1.1', '2'):
|
||||
continue
|
||||
if not filter_value or endpoint.get(attr) == filter_value:
|
||||
endpoint["serviceName"] = service.get("name")
|
||||
matching_endpoints.append(endpoint)
|
||||
|
@ -38,23 +38,34 @@ SERVICE_CATALOG = {
|
||||
"type": "compute",
|
||||
"endpoints": [
|
||||
{
|
||||
# Tenant 1, no region, v1.0
|
||||
"tenantId": "1",
|
||||
"publicURL": "https://compute1.host/v1/1234",
|
||||
"internalURL": "https://compute1.host/v1/1234",
|
||||
"region": "North",
|
||||
"publicURL": "https://compute1.host/v1/1",
|
||||
"internalURL": "https://compute1.host/v1/1",
|
||||
"versionId": "1.0",
|
||||
"versionInfo": "https://compute1.host/v1.0/",
|
||||
"versionList": "https://compute1.host/"
|
||||
},
|
||||
{
|
||||
# Tenant 2, with region, v1.1
|
||||
"tenantId": "2",
|
||||
"publicURL": "https://compute1.host/v1.1/3456",
|
||||
"internalURL": "https://compute1.host/v1.1/3456",
|
||||
"publicURL": "https://compute1.host/v1.1/2",
|
||||
"internalURL": "https://compute1.host/v1.1/2",
|
||||
"region": "North",
|
||||
"versionId": "1.1",
|
||||
"versionInfo": "https://compute1.host/v1.1/",
|
||||
"versionList": "https://compute1.host/"
|
||||
},
|
||||
{
|
||||
# Tenant 1, with region, v2.0
|
||||
"tenantId": "1",
|
||||
"publicURL": "https://compute1.host/v2/1",
|
||||
"internalURL": "https://compute1.host/v2/1",
|
||||
"region": "North",
|
||||
"versionId": "2",
|
||||
"versionInfo": "https://compute1.host/v2/",
|
||||
"versionList": "https://compute1.host/"
|
||||
},
|
||||
],
|
||||
"endpoints_links": [],
|
||||
},
|
||||
@ -64,8 +75,8 @@ SERVICE_CATALOG = {
|
||||
"endpoints": [
|
||||
{
|
||||
"tenantId": "1",
|
||||
"publicURL": "https://volume1.host/v1/1234",
|
||||
"internalURL": "https://volume1.host/v1/1234",
|
||||
"publicURL": "https://volume1.host/v1/1",
|
||||
"internalURL": "https://volume1.host/v1/1",
|
||||
"region": "South",
|
||||
"versionId": "1.0",
|
||||
"versionInfo": "uri",
|
||||
@ -73,8 +84,8 @@ SERVICE_CATALOG = {
|
||||
},
|
||||
{
|
||||
"tenantId": "2",
|
||||
"publicURL": "https://volume1.host/v1.1/3456",
|
||||
"internalURL": "https://volume1.host/v1.1/3456",
|
||||
"publicURL": "https://volume1.host/v1.1/2",
|
||||
"internalURL": "https://volume1.host/v1.1/2",
|
||||
"region": "South",
|
||||
"versionId": "1.1",
|
||||
"versionInfo": "https://volume1.host/v1.1/",
|
||||
@ -106,9 +117,9 @@ class ServiceCatalogTest(utils.TestCase):
|
||||
self.assertRaises(exceptions.AmbiguousEndpoints, sc.url_for,
|
||||
service_type='compute')
|
||||
self.assertEquals(sc.url_for('tenantId', '1', service_type='compute'),
|
||||
"https://compute1.host/v1/1234")
|
||||
"https://compute1.host/v2/1")
|
||||
self.assertEquals(sc.url_for('tenantId', '2', service_type='compute'),
|
||||
"https://compute1.host/v1.1/3456")
|
||||
"https://compute1.host/v1.1/2")
|
||||
|
||||
self.assertRaises(exceptions.EndpointNotFound, sc.url_for,
|
||||
"region", "South", service_type='compute')
|
||||
@ -119,9 +130,9 @@ class ServiceCatalogTest(utils.TestCase):
|
||||
self.assertRaises(exceptions.AmbiguousEndpoints, sc.url_for,
|
||||
service_type='volume')
|
||||
self.assertEquals(sc.url_for('tenantId', '1', service_type='volume'),
|
||||
"https://volume1.host/v1/1234")
|
||||
"https://volume1.host/v1/1")
|
||||
self.assertEquals(sc.url_for('tenantId', '2', service_type='volume'),
|
||||
"https://volume1.host/v1.1/3456")
|
||||
"https://volume1.host/v1.1/2")
|
||||
|
||||
self.assertRaises(exceptions.EndpointNotFound, sc.url_for,
|
||||
"region", "North", service_type='volume')
|
||||
|
Loading…
x
Reference in New Issue
Block a user