Filtering for resource tags does not work when calling search_*
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
openstacksdk |
New
|
Undecided
|
Unassigned |
Bug Description
While working with the Ansible Openstack.Cloud collection I was trying to figure out why filtering for resource tags is not working. After a little diggin', it turns out that this problem is actually caused by the openstacksdk.
The openstacksdk connection object exposes different methods to search for resource types, which are still used by the Openstack.Cloud collection to retrieve data from the API:
- search_projects
- search_images (btw, this one is not included in the documentation, see https:/
- search_containers
- etc.
When trying to filter for resource tags, these methods always return an empty list, even if the tags are valid. This is caused by the cloud._
One concrete example (code to easily reproduce these steps below):
When calling search_projects(), it calls list_projects():
https:/
Which, in turn, calls projects(**query):
https:/
Then, search_projects() passes the resulting list (which is already filtered correctly mind you) to the cloud._
Now, interestingly, search_routers() does NOT call the _utils.
https:/
It is also quite telling that the search_* functions are marked as deprecated:
https:/
Code to reproduce these issue:
Note: When reading the debug log output, we can see that the response body always contains the correct data, so the filtering issue is really on the client side caused by _utils._filter_list
import openstack
openstack.
conn = openstack.
a = conn.identity.
b = conn.search_
r = conn.search_
print(list(a))
print(b)
print(r)
A few solutions to this problem:
- Remove the use of the _utils._filter_list function and put it in a museum.
- Fix this function so the returned values are correct. Also, while fixing it, please make this code more readable.
- Deprecate and remove the search_* functions altogether.
Bug https:/
Once a decision has been made on this topic, I am more that happy to provide patches!
summary: |
- Filtering for resource tags does not work + Filtering for resource tags does not work when calling search_* |