openstacksdk/releasenotes/notes/resource-find-filter-by-name-e647e5c507ff4b6c.yaml
Rodolfo Alonso Hernandez 790fefbccd Add "name" filter in "list" call when retrieving a single register
Resource.find() function accepts both the ID or the name of a register.
First tries to retrieve the register by calling the server API using
the identifier given. By default, all OpenStack API will accept the ID
of the register (which is unique). If this call fails, the function
retrieves the list of all registers in the table.

This last call is very inefficient if the number of elements is high.
The bug description documents the time needed to retrieve a list of
1000 ports.

Instead of this, this patch uses the filtering options available in the
servers APIs. This filter will be applied in the database call and the
number of registers returned will be limited to only those ones
matching the "name" field.

In case the API doesn't support this filtering parameter, a
"InvalidResourceQuery" will be risen and the function will retrieve
again the list of registers in the database without filtering by "name".

Change-Id: I8bb6f46f66249aeae0649c8f6596f9269e3518a5
Related-Bug: #1779882
2019-04-25 13:45:57 +00:00

8 lines
315 B
YAML

---
other:
- |
``openstack.resource.Resource.find`` now can use the database back-end to
filter by name. If the resource class has "name" in the query parameters,
this function will add this filter parameter in the "list" command, instead
of retrieving the whole list and then manually filtering.