Neutron – get list of external (floating) networks

Neutron – get list of external (floating) networks

Should be easy to get all external network (floating ip networks) from your environment, right? At least, I though so. But! It wasn’t so easy like I imaged before trying to code it in my python script.

I tried to get list of external network for some days. Then took a break to clear my mind. After a few weeks i came back to solve this because our environment was on short with FIPs and we needed to have some possibility to check how many FIPs we still have available.

Sure, there is a Neutron CLI command  neutron net-ip-availability-list but! we use OpenContrail (Tungsten Fabric, now) and this call is not supported.

So there should be possibility to filter results of listing Neutron networks, let’s look into this.

I have tried following pieces of code but no one of them works:

After a quite long googling i came over this RFE https://bugs.launchpad.net/neutron/+bug/1475792 and I have reused the search_opts for my use case:

WOW! I got them.  extnets is a list of external networks.

I just started with python, so I can’t comment why at least the second line of previous code block doesn’t work.

 

TL;DR

To get list of external networks use  search_opts .

Comments are closed.