Woot4Moo
Woot4Moo

Reputation: 24316

Nova Python Client - List available IP addresses

I have been using:

nova.floating_ips.list()

to retrieve all known floating IP addresses within my OpenStack deployment, is there a known way to retrieve only the available IP addresses? That is I don't want IP addresses that have already been assigned.

Upvotes: 2

Views: 534

Answers (1)

larsks
larsks

Reputation: 311606

The floating_ips.list() method returns a list of floating ips, where each address has the following attributes:

  • fixed_ip
  • id
  • instance_id
  • ip
  • pool

If you filter the list of address with instance_id is None, you'll get a list of floating ips that are not currently in use:

unused_ips = [addr for addr in nova.floating_ips.list() if addr.instance_id is None]

Upvotes: 3

Related Questions