[RFE] Extended resources should not always calculate all attributes
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
neutron |
Confirmed
|
Wishlist
|
Unassigned |
Bug Description
Currently [1] resource extensions are asked to retrieve all attributes when calling resource_extend.
This poses some problems:
- Extensions need to gather all attributes for the resource they extend
- ML2 mechanism drivers cannot make a difference between list and show of an object
We propose to:
A) Add a 'fields' argument to the extensions functions. This 'fields' argument is already present when creating the object dictionary, typically passed from ?fields=x parameters through the api.
Passing it to resource extensions would prevent them from calculating attributes that will be discarded anyway.
B) Let the clients when calling the API for list functions, use the 'fields' parameters to restrict the fields that are returned.
We think this is a positive improvement as it:
1) Prevents unneeded data transfer between api and client.
2) Provides the ability for extensions that are interfacing with external components (like an SDN controller) to only process the requested attributes.
The purpose of this RFE is to gather your comments before we start any devwork.
Components that would need changing:
- Neutron: resource_extend and all calling functions
- Ml2: extension drivers
(Both needing full backwards compatibility)
- openstackclient & openstack sdk: list api calls need to include ?fields parameters
- neutronclient: list api calls need to include ?fields parameters
- neutron-
[1]https:/
Changed in neutron: | |
assignee: | nobody → Tom Stappaerts (tstappae) |
information type: | Public → Public Security |
information type: | Public Security → Private Security |
information type: | Private Security → Public |
tags: | added: rfe |
Agreed that we may want to filter out extensions that won't participate in returned payload formation. One thing worth noticing is that I don't think we actually send all the data to the client that then filters out unneeded fields, as you seem to imply. Instead, we call db_utils. resource_ fields( res, fields) before passing the payload dict to the root api layer, the function that filters out fields not explicitly requested. If that's the case, I am not sure which new API tests you suggest to implement. (The current API behaviour is already as expected; of course additional coverage for the 'fields' feature is welcome if it's not good enough, but this matter is independent of the proposal).
My understanding is that in case of what you propose, we would need to know which fields are generated by each registered extension, to know which extension to call to. Then extensions could also do additional filtering by themselves in case when they serve multiple fields. This probably requires a new extension registration API that would support both of these features. Is it what you envision?