Merge "Handle catalog backends that don't support all functions."
This commit is contained in:
commit
70c759bc0d
@ -407,11 +407,19 @@ class EndpointFilterV3Controller(controller.V3Controller):
|
||||
payload):
|
||||
project_or_endpoint_id = payload['resource_info']
|
||||
if resource_type == 'project':
|
||||
self.catalog_api.delete_association_by_project(
|
||||
project_or_endpoint_id)
|
||||
try:
|
||||
self.catalog_api.delete_association_by_project(
|
||||
project_or_endpoint_id)
|
||||
except exception.NotImplemented:
|
||||
# Some catalog drivers don't support this
|
||||
pass
|
||||
else:
|
||||
self.catalog_api.delete_association_by_endpoint(
|
||||
project_or_endpoint_id)
|
||||
try:
|
||||
self.catalog_api.delete_association_by_endpoint(
|
||||
project_or_endpoint_id)
|
||||
except exception.NotImplemented:
|
||||
# Some catalog drivers don't support this
|
||||
pass
|
||||
|
||||
@controller.protected()
|
||||
def add_endpoint_to_project(self, request, project_id, endpoint_id):
|
||||
@ -581,9 +589,13 @@ class ProjectEndpointGroupV3Controller(controller.V3Controller):
|
||||
def _on_project_delete(self, service, resource_type,
|
||||
operation, payload):
|
||||
project_id = payload['resource_info']
|
||||
(self.catalog_api.
|
||||
delete_endpoint_group_association_by_project(
|
||||
project_id))
|
||||
try:
|
||||
(self.catalog_api.
|
||||
delete_endpoint_group_association_by_project(
|
||||
project_id))
|
||||
except exception.NotImplemented:
|
||||
# Some catalog drivers don't support this
|
||||
pass
|
||||
|
||||
@controller.protected()
|
||||
def get_endpoint_group_in_project(self, request, endpoint_group_id,
|
||||
|
@ -305,7 +305,7 @@ class RestfulTestCase(unit.SQLDriverOverrides, rest.RestfulTestCase,
|
||||
name=u'Default')
|
||||
self.resource_api.create_domain(DEFAULT_DOMAIN_ID, domain)
|
||||
|
||||
def load_sample_data(self):
|
||||
def load_sample_data(self, create_region_and_endpoints=True):
|
||||
self._populate_default_domain()
|
||||
self.domain = unit.new_domain_ref()
|
||||
self.domain_id = self.domain['id']
|
||||
@ -354,22 +354,24 @@ class RestfulTestCase(unit.SQLDriverOverrides, rest.RestfulTestCase,
|
||||
self.default_domain_project_id,
|
||||
self.role_id)
|
||||
|
||||
self.region = unit.new_region_ref()
|
||||
self.region_id = self.region['id']
|
||||
self.catalog_api.create_region(self.region)
|
||||
if create_region_and_endpoints:
|
||||
self.region = unit.new_region_ref()
|
||||
self.region_id = self.region['id']
|
||||
self.catalog_api.create_region(self.region)
|
||||
|
||||
self.service = unit.new_service_ref()
|
||||
self.service_id = self.service['id']
|
||||
self.catalog_api.create_service(self.service_id, self.service.copy())
|
||||
self.service = unit.new_service_ref()
|
||||
self.service_id = self.service['id']
|
||||
self.catalog_api.create_service(self.service_id,
|
||||
self.service.copy())
|
||||
|
||||
self.endpoint = unit.new_endpoint_ref(service_id=self.service_id,
|
||||
interface='public',
|
||||
region_id=self.region_id)
|
||||
self.endpoint_id = self.endpoint['id']
|
||||
self.catalog_api.create_endpoint(self.endpoint_id,
|
||||
self.endpoint.copy())
|
||||
# The server adds 'enabled' and defaults to True.
|
||||
self.endpoint['enabled'] = True
|
||||
self.endpoint = unit.new_endpoint_ref(service_id=self.service_id,
|
||||
interface='public',
|
||||
region_id=self.region_id)
|
||||
self.endpoint_id = self.endpoint['id']
|
||||
self.catalog_api.create_endpoint(self.endpoint_id,
|
||||
self.endpoint.copy())
|
||||
# The server adds 'enabled' and defaults to True.
|
||||
self.endpoint['enabled'] = True
|
||||
|
||||
def create_new_default_project_for_user(self, user_id, domain_id,
|
||||
enable_project=True):
|
||||
|
@ -940,3 +940,30 @@ class TestCatalogAPISQLRegions(unit.TestCase):
|
||||
for k in keys:
|
||||
self.assertEqual(ref.get(k), entity[k], k)
|
||||
self.assertEqual(entity['region_id'], entity['region'])
|
||||
|
||||
|
||||
class TestCatalogAPITemplatedProject(test_v3.RestfulTestCase):
|
||||
"""Templated Catalog doesn't support full API.
|
||||
|
||||
Eg. No region/endpoint creation.
|
||||
|
||||
"""
|
||||
|
||||
def config_overrides(self):
|
||||
super(TestCatalogAPITemplatedProject, self).config_overrides()
|
||||
self.config_fixture.config(group='catalog', driver='templated')
|
||||
|
||||
def load_fixtures(self, fixtures):
|
||||
self.load_sample_data(create_region_and_endpoints=False)
|
||||
|
||||
def test_project_delete(self):
|
||||
"""Deleting a project should not result in an 500 ISE.
|
||||
|
||||
The EndpointFilter extension of the Catalog API will create a
|
||||
notification when a project is deleted (attempting to clean up
|
||||
project->endpoint relationships). In the case of a templated catalog,
|
||||
no deletions (via catalog_api.delete_association_by_project) can be
|
||||
performed and result in a NotImplemented exception. We catch this
|
||||
exception and ignore it since it is expected.
|
||||
"""
|
||||
self.resource_api.delete_project(self.project_id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user