Merge "Move logic for catalog driver differences to manager"
This commit is contained in:
commit
7923a46692
@ -409,19 +409,11 @@ class EndpointFilterV3Controller(controller.V3Controller):
|
||||
payload):
|
||||
project_or_endpoint_id = payload['resource_info']
|
||||
if resource_type == 'project':
|
||||
try:
|
||||
self.catalog_api.delete_association_by_project(
|
||||
project_or_endpoint_id)
|
||||
except exception.NotImplemented:
|
||||
# Some catalog drivers don't support this
|
||||
pass
|
||||
self.catalog_api.delete_association_by_project(
|
||||
project_or_endpoint_id)
|
||||
else:
|
||||
try:
|
||||
self.catalog_api.delete_association_by_endpoint(
|
||||
project_or_endpoint_id)
|
||||
except exception.NotImplemented:
|
||||
# Some catalog drivers don't support this
|
||||
pass
|
||||
self.catalog_api.delete_association_by_endpoint(
|
||||
project_or_endpoint_id)
|
||||
|
||||
@controller.protected()
|
||||
def add_endpoint_to_project(self, request, project_id, endpoint_id):
|
||||
@ -591,13 +583,8 @@ class ProjectEndpointGroupV3Controller(controller.V3Controller):
|
||||
def _on_project_delete(self, service, resource_type,
|
||||
operation, payload):
|
||||
project_id = payload['resource_info']
|
||||
try:
|
||||
(self.catalog_api.
|
||||
delete_endpoint_group_association_by_project(
|
||||
project_id))
|
||||
except exception.NotImplemented:
|
||||
# Some catalog drivers don't support this
|
||||
pass
|
||||
self.catalog_api.delete_endpoint_group_association_by_project(
|
||||
project_id)
|
||||
|
||||
@controller.protected()
|
||||
def get_endpoint_group_in_project(self, request, endpoint_group_id,
|
||||
|
@ -249,6 +249,14 @@ class Manager(manager.Manager):
|
||||
endpoint_group_id, project_id)
|
||||
COMPUTED_CATALOG_REGION.invalidate()
|
||||
|
||||
def delete_endpoint_group_association_by_project(self, project_id):
|
||||
try:
|
||||
self.driver.delete_endpoint_group_association_by_project(
|
||||
project_id)
|
||||
except exception.NotImplemented:
|
||||
# Some catalog drivers don't support this
|
||||
pass
|
||||
|
||||
def get_endpoint_groups_for_project(self, project_id):
|
||||
# recover the project endpoint group memberships and for each
|
||||
# membership recover the endpoint group
|
||||
@ -309,6 +317,20 @@ class Manager(manager.Manager):
|
||||
|
||||
return filtered_endpoints
|
||||
|
||||
def delete_association_by_endpoint(self, endpoint_id):
|
||||
try:
|
||||
self.driver.delete_association_by_endpoint(endpoint_id)
|
||||
except exception.NotImplemented:
|
||||
# Some catalog drivers don't support this
|
||||
pass
|
||||
|
||||
def delete_association_by_project(self, project_id):
|
||||
try:
|
||||
self.driver.delete_association_by_project(project_id)
|
||||
except exception.NotImplemented:
|
||||
# Some catalog drivers don't support this
|
||||
pass
|
||||
|
||||
|
||||
@versionutils.deprecated(
|
||||
versionutils.deprecated.NEWTON,
|
||||
|
@ -262,3 +262,21 @@ class TestTemplatedCatalog(unit.TestCase, catalog_tests.CatalogTests):
|
||||
@unit.skip_if_cache_disabled('catalog')
|
||||
def test_invalidate_cache_when_updating_endpoint(self):
|
||||
self.skip_test_overrides(BROKEN_WRITE_FUNCTIONALITY_MSG)
|
||||
|
||||
def test_delete_endpoint_group_association_by_project(self):
|
||||
# Deleting endpoint group association is not supported by the templated
|
||||
# driver, but it should be silent about it and not raise an error.
|
||||
self.catalog_api.delete_endpoint_group_association_by_project(
|
||||
uuid.uuid4().hex)
|
||||
|
||||
def test_delete_association_by_endpoint(self):
|
||||
# Deleting endpoint association is not supported by the templated
|
||||
# driver, but it should be silent about it and not raise an error.
|
||||
self.catalog_api.delete_association_by_endpoint(
|
||||
uuid.uuid4().hex)
|
||||
|
||||
def test_delete_association_by_project(self):
|
||||
# Deleting endpoint association is not supported by the templated
|
||||
# driver, but it should be silent about it and not raise an error.
|
||||
self.catalog_api.delete_association_by_project(
|
||||
uuid.uuid4().hex)
|
||||
|
@ -959,11 +959,17 @@ class TestCatalogAPITemplatedProject(test_v3.RestfulTestCase):
|
||||
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.
|
||||
Deleting a project will create a notification, which the EndpointFilter
|
||||
functionality will use to clean up any project->endpoint and
|
||||
project->endpoint_group relationships. The templated catalog does not
|
||||
support such relationships, but the act of attempting to delete them
|
||||
should not cause a NotImplemented exception to be exposed to an API
|
||||
caller.
|
||||
|
||||
Deleting an endpoint has a similar notification and clean up
|
||||
mechanism, but since we do not allow deletion of endpoints with the
|
||||
templated catalog, there is no testing to do for that action.
|
||||
"""
|
||||
self.resource_api.delete_project(self.project_id)
|
||||
self.delete(
|
||||
'/projects/%(project_id)s' % {
|
||||
'project_id': self.project_id})
|
||||
|
Loading…
x
Reference in New Issue
Block a user