From d2492ec557e9180bf0eb8c3a464ea930bf4f642a Mon Sep 17 00:00:00 2001 From: Boris Bobrov Date: Sun, 15 Mar 2026 00:56:02 +0100 Subject: [PATCH] Remove V2 get_catalog from catalog driver The get_catalog method on the catalog driver interface and its SQL implementation format the service catalog in the legacy V2 layout. Since the V2 API was removed, no code path calls this method. The entire codebase uses get_v3_catalog exclusively. Remove the abstract definition and the ~65-line SQL implementation to reduce dead code. Generated-By: claude-opus-4-6 (OpenCode) Signed-off-by: Boris Bobrov Change-Id: Ib6eb3d5cb200784fb30aeb031d082d33b097399f --- keystone/catalog/backends/base.py | 25 ------------ keystone/catalog/backends/sql.py | 65 ------------------------------- 2 files changed, 90 deletions(-) diff --git a/keystone/catalog/backends/base.py b/keystone/catalog/backends/base.py index b1a9c8ac12..cd4b87536e 100644 --- a/keystone/catalog/backends/base.py +++ b/keystone/catalog/backends/base.py @@ -209,31 +209,6 @@ class CatalogDriverBase(provider_api.ProviderAPIMixin, metaclass=abc.ABCMeta): """ raise exception.NotImplemented() # pragma: no cover - @abc.abstractmethod - def get_catalog(self, user_id, project_id): - """Retrieve and format the current service catalog. - - Example:: - - { 'RegionOne': - {'compute': { - 'adminURL': u'http://host:8774/v1.1/project_id', - 'internalURL': u'http://host:8774/v1.1/project_id', - 'name': 'Compute Service', - 'publicURL': u'http://host:8774/v1.1/project_id'}, - 'ec2': { - 'adminURL': 'http://host:8773/services/Admin', - 'internalURL': 'http://host:8773/services/Cloud', - 'name': 'EC2 Service', - 'publicURL': 'http://host:8773/services/Cloud'}} - - :returns: A nested dict representing the service catalog or an - empty dict. - :raises keystone.exception.NotFound: If the endpoint doesn't exist. - - """ - raise exception.NotImplemented() # pragma: no cover - def get_v3_catalog(self, user_id, project_id): """Retrieve and format the current V3 service catalog. diff --git a/keystone/catalog/backends/sql.py b/keystone/catalog/backends/sql.py index d1697f6898..5e3f15b4ea 100644 --- a/keystone/catalog/backends/sql.py +++ b/keystone/catalog/backends/sql.py @@ -273,71 +273,6 @@ class Catalog(base.CatalogDriverBase): ref.extra = new_endpoint.extra return ref.to_dict() - def get_catalog(self, user_id, project_id): - """Retrieve and format the V2 service catalog. - - :param user_id: The id of the user who has been authenticated for - creating service catalog. - :param project_id: The id of the project. 'project_id' will be None - in the case this being called to create a catalog to go in a - domain scoped token. In this case, any endpoint that requires - a project_id as part of their URL will be skipped (as would a whole - service if, as a consequence, it has no valid endpoints). - - :returns: A nested dict representing the service catalog or an - empty dict. - - """ - substitutions = dict(CONF.items()) - substitutions.update({'user_id': user_id}) - silent_keyerror_failures = [] - if project_id: - substitutions.update( - {'tenant_id': project_id, 'project_id': project_id} - ) - else: - silent_keyerror_failures = ['tenant_id', 'project_id'] - - with sql.session_for_read() as session: - endpoints = ( - session.query(Endpoint) - .options(sql.joinedload(Endpoint.service)) - .filter(Endpoint.enabled == true()) - .all() - ) - - catalog = {} - - for endpoint in endpoints: - if not endpoint.service['enabled']: - continue - try: - formatted_url = utils.format_url( - endpoint['url'], - substitutions, - silent_keyerror_failures=silent_keyerror_failures, - ) - if formatted_url is not None: - url = formatted_url - else: - continue - except exception.MalformedEndpoint: # nosec(tkelsey) - continue # this failure is already logged in format_url() - - region = endpoint['region_id'] - service_type = endpoint.service['type'] - default_service = { - 'id': endpoint['id'], - 'name': endpoint.service.extra.get('name', ''), - 'publicURL': '', - } - catalog.setdefault(region, {}) - catalog[region].setdefault(service_type, default_service) - interface_url = '{}URL'.format(endpoint['interface']) - catalog[region][service_type][interface_url] = url - - return catalog - def get_v3_catalog(self, user_id, project_id): """Retrieve and format the current V3 service catalog.