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 <b.bobrov@sap.com> Change-Id: Ib6eb3d5cb200784fb30aeb031d082d33b097399f
This commit is contained in:
2 files changed
-90
No files matched your search
@@ -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.
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
Reference in new issue
Block a user