diff options
| author | Anton Frolov <af9740@att.com> | 2017-09-25 12:31:24 -0700 |
|---|---|---|
| committer | Anton Frolov <af9740@att.com> | 2017-09-26 14:31:07 -0700 |
| commit | f6f5ce03c5b8a03180db24a02dda5b30f40b4cee (patch) | |
| tree | 2c5355d1dd26e73a284defa810b63fc2563666e7 /openstackclient/identity/common.py | |
| parent | 953d74b5d65b095428c783f80cc61f2d85909841 (diff) | |
| download | python-openstackclient-f6f5ce03c5b8a03180db24a02dda5b30f40b4cee.tar.gz | |
Optimize getting endpoint list
Currently ListEndpoint.take_action method unconditionally iterates
over all endpoints and issue GET /v3/services/<ep.service_id>
request for each endpoint. In case of HTTPS keystone endpoint this
can take significant amout of time, and it only getting worse in
case of multiple regions.
This commit change this logic to making just two GET requests: first
it gets endpoint list, then it gets service list, searching service
in the list instead of issuing GET /v3/services/<id> request.
Change-Id: I22b61c0b45b0205a2f5a4608c2473cb7814fe3cf
Closes-Bug: 1719413
Diffstat (limited to 'openstackclient/identity/common.py')
| -rw-r--r-- | openstackclient/identity/common.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/openstackclient/identity/common.py b/openstackclient/identity/common.py index 3dc5adbb..e119f660 100644 --- a/openstackclient/identity/common.py +++ b/openstackclient/identity/common.py @@ -26,6 +26,16 @@ from osc_lib import utils 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): """Find a service by id, name or type.""" |
