Merge "Optimize getting endpoint list"
This commit is contained in:
commit
33403348a2
@ -26,6 +26,16 @@ from osc_lib import utils
|
|||||||
from openstackclient.i18n import _
|
from openstackclient.i18n import _
|
||||||
|
|
||||||
|
|
||||||
|
def find_service_in_list(service_list, service_id):
|
||||||
|
"""Find a service by id in service list."""
|
||||||
|
|
||||||
|
for service in service_list:
|
||||||
|
if service.id == service_id:
|
||||||
|
return service
|
||||||
|
raise exceptions.CommandError(
|
||||||
|
"No service with a type, name or ID of '%s' exists." % service_id)
|
||||||
|
|
||||||
|
|
||||||
def find_service(identity_client, name_type_or_id):
|
def find_service(identity_client, name_type_or_id):
|
||||||
"""Find a service by id, name or type."""
|
"""Find a service by id, name or type."""
|
||||||
|
|
||||||
|
@ -167,9 +167,10 @@ class ListEndpoint(command.Lister):
|
|||||||
if parsed_args.region:
|
if parsed_args.region:
|
||||||
kwargs['region'] = parsed_args.region
|
kwargs['region'] = parsed_args.region
|
||||||
data = identity_client.endpoints.list(**kwargs)
|
data = identity_client.endpoints.list(**kwargs)
|
||||||
|
service_list = identity_client.services.list()
|
||||||
|
|
||||||
for ep in data:
|
for ep in data:
|
||||||
service = common.find_service(identity_client, ep.service_id)
|
service = common.find_service_in_list(service_list, ep.service_id)
|
||||||
ep.service_name = get_service_name(service)
|
ep.service_name = get_service_name(service)
|
||||||
ep.service_type = service.type
|
ep.service_type = service.type
|
||||||
return (columns,
|
return (columns,
|
||||||
|
@ -295,6 +295,7 @@ class TestEndpointList(TestEndpoint):
|
|||||||
|
|
||||||
# This is the return value for common.find_resource(service)
|
# This is the return value for common.find_resource(service)
|
||||||
self.services_mock.get.return_value = self.service
|
self.services_mock.get.return_value = self.service
|
||||||
|
self.services_mock.list.return_value = [self.service]
|
||||||
|
|
||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = endpoint.ListEndpoint(self.app, None)
|
self.cmd = endpoint.ListEndpoint(self.app, None)
|
||||||
@ -726,6 +727,7 @@ class TestEndpointListServiceWithoutName(TestEndpointList):
|
|||||||
|
|
||||||
# This is the return value for common.find_resource(service)
|
# This is the return value for common.find_resource(service)
|
||||||
self.services_mock.get.return_value = self.service
|
self.services_mock.get.return_value = self.service
|
||||||
|
self.services_mock.list.return_value = [self.service]
|
||||||
|
|
||||||
# Get the command object to test
|
# Get the command object to test
|
||||||
self.cmd = endpoint.ListEndpoint(self.app, None)
|
self.cmd = endpoint.ListEndpoint(self.app, None)
|
||||||
|
8
releasenotes/notes/bug-1719413-0401d05c91cc9094.yaml
Normal file
8
releasenotes/notes/bug-1719413-0401d05c91cc9094.yaml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fix an issue with ``endpoint list`` working slow because it is issuing one GET
|
||||||
|
request to /v3/services/<id> Keystone API for each endpoint. In case of HTTPS
|
||||||
|
keystone endpoint and multiple regions it can take significant amount of time.
|
||||||
|
[Bug `1719413 <https://bugs.launchpad.net/python-openstackclient/+bug/1719413>`_]
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user