Ask Your Question
0

How to Filter Floating IPs with Neutron Python API?

asked 2015-10-14 18:44:17 -0600

mattr gravatar image

I'm utilizing the Neutron Python API to attempt to filter for a specific Floating IP using the https://github.com/openstack/python-neutronclient/blob/master/neutronclient/v2_0/client.py#L730 (neutron.list_floatingips()) method. In essence, I'm attempting to mimic this behavior:

$ neutron floatingip-list --tenant-id xxx | grep 15.xxx.xx.xx
| 4ec7639a-47ca-40a8-8cd9-7bc5272f666f | 10.0.0.15 | 15.xxx.xx.xx | 64994354-4921-48ce-b819-d34d194c631c |

The issue is when performing the call to the API as such:

>>> neutron.list_floatingips()

It will return a dictionary object with ALL of the Floating IPs under the tenant, when only a specific IP needs to be returned. I've attempted (in a few different ways) to filter the results, similar to below:

>>> neutron.list_floatingips(filter_value={'floating_ip_address': '15.xxx.xx.xx'})

It still returns the same results as when not including an argument. So my question is, what is the argument to be expected in order to filter for this specific value?

I'm aware I could potentially filter through the resulting dictionary values; however, I'm trying to avoid having the API return more results than necessary.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2015-11-04 15:55:41 -0600

mattr gravatar image

The solution is as follows:

neutron.list_floatingips(floating_ip_address='15.1.1.5')
{'floatingips': [{u'router_id': None, u'status': u'ACTIVE', u'tenant_id': u'8537ba5eb1d74d42ac22dcf840c4081a', u'floating_network_id': u'd06e2261-e3c7-4753-afaa-de3efe371f1f', u'fixed_ip_address': None, u'floating_ip_address': u'15.1.1.5', u'port_id': None, u'id': u'ca22da1f-cce0-4d73-98d2-21522313b15f'}]}
>>>
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2015-10-14 18:42:00 -0600

Seen: 544 times

Last updated: Nov 04 '15