Use valid filters to list floating IPs in neutron
Shade used 'attached' as a filter for listing floating IPs, but this is not a supported parameter in neutron. In before, the test passed because neutron server ignored this parameter and returned all the floating IPs. However, neutron is planing to employ a strict validation on the list endpoint [1]. As a result, neutron will reject the request with 400 response if the request contains unknown filter. This patch fixes the usage of neutron API. It passes filters to neutron API only if they are known supported filters. The list of supported filters for listing floating IPs can be found in the neutron API reference [2]. [1] https://review.openstack.org/#/c/574907/ [2] https://developer.openstack.org/api-ref/network/v2/#id130 Change-Id: I124adfc5e9cdd5bc20aacf23f9dcc10c55b0870b
This commit is contained in:
parent
ebf7f58763
commit
51e2989fd0
@ -1407,7 +1407,15 @@ class OpenStackCloud(
|
||||
# `filters` could be a jmespath expression which Neutron server doesn't
|
||||
# understand, obviously.
|
||||
if self._use_neutron_floating() and isinstance(filters, dict):
|
||||
kwargs = {'filters': filters}
|
||||
filter_keys = ['router_id', 'status', 'tenant_id', 'project_id',
|
||||
'revision_number', 'description',
|
||||
'floating_network_id', 'fixed_ip_address',
|
||||
'floating_ip_address', 'port_id', 'sort_dir',
|
||||
'sort_key', 'tags', 'tags-any', 'not-tags',
|
||||
'not-tags-any', 'fields']
|
||||
neutron_filters = {k: v for k, v in filters.items()
|
||||
if k in filter_keys}
|
||||
kwargs = {'filters': neutron_filters}
|
||||
else:
|
||||
kwargs = {}
|
||||
floating_ips = self.list_floating_ips(**kwargs)
|
||||
|
@ -190,8 +190,7 @@ class TestFloatingIP(base.RequestsMockTestCase):
|
||||
def test_search_floating_ips(self):
|
||||
self.register_uris([
|
||||
dict(method='GET',
|
||||
uri=('https://network.example.com/v2.0/floatingips.json'
|
||||
'?attached=False'),
|
||||
uri=('https://network.example.com/v2.0/floatingips.json'),
|
||||
json=self.mock_floating_ip_list_rep)])
|
||||
|
||||
floating_ips = self.cloud.search_floating_ips(
|
||||
|
Loading…
x
Reference in New Issue
Block a user