allow filters to use 'like' operation of sqlalchemy
currently, the get_xxxs use the in_ to query the resources in filters parameter. It cannot deal with the requirement like ' to list all of the ports which have the ip address like this '10.0.%', or to list all of the network the name of which is like 'test_network%'.
This BP will add an way to deal with it.
for top field:
quantum net-list --name test_network% x_query=like
query = query.filter(
for sub field:
quantum port-list --fixed-ips ip_address~=10.0.%
query = query.filter(
for API compatible:
we will use the current filters parameter:
quantum net-list --name test_network% x_query=like
filters = {'name': [test_network%],
quantum port-list --fixed-ips ip_address~=10.0.%
filters = {'fixed-ips': {'ip_address': ['10.0.%']},
Blueprint information
- Status:
- Complete
- Approver:
- Salvatore Orlando
- Priority:
- Undefined
- Drafter:
- None
- Direction:
- Approved
- Assignee:
- yong sheng gong
- Definition:
- Obsolete
- Series goal:
- None
- Implementation:
- Needs Code Review
- Milestone target:
- next
- Started by
- yong sheng gong
- Completed by
- Armando Migliaccio
Related branches
Sprints
Whiteboard
Dec-07-2015(armax): If someone is interested in pursuing it, this must be re-submitted according to guidelines defined in [1].
[1] http://
-----------
4-Sep: Moving to next for possible inclusion into Icehouse.
Jordan P : I am not sure about this one. I find the x_query=like, the % and ~= notations not elegant. I would rather try to detect if the submitted IPs are complete (4 bytes) and if not make use the LIKE SQL operator (more precisely : use the SQL Alchemy helper). For the network name, it seems reasonable to always use a "like" query.
One should also note that currently the filter is done with an IN operator which allow several values to be passed.
Update 2013-05-24:
- Set Salvatore Orlando as approver, waiting for specification
- Regardless of implementation/
(yong sheng gong said on 2013-05-25): nova help list:
--ip <ip-regexp> Search with regular expression match by IP address
--ip6 <ip6-regexp> Search with regular expression match by IPv6 address
--name <name-regexp> Search with regular expression match by name
--instance-name <name-regexp>
and I want our API have a generic way to deal with 'filters' using regex besides the current 'in_'. so that we can deal with 'quantum xxx-list --anyattr regext-value'.
(yong sheng gong said on 2013-07-25):
to keep compliance with in_, we have to make a difference, for example we have to add action=regex into neutron client command.
neutron net-list --name action=regex n[x]]x
Gerrit topic: https:/
Addressed by: https:/
allow regex in List operation of API