Ask Your Question

Get floating ip for instance

asked 2016-06-14 07:36:06 -0500

alvaroaleman gravatar image

Hello there,

I'm looking for a simple way to get the floating ip of an instance, something like:

openstack get-floating-ip $instanceid

Currently the best solutions I've been able to figure out is to use:

openstack server show $instanceid -f value -c addresses|tr ',' '\n'|tr -d ' '|grep -v '='

This does however heavily rely on assumptions how the output of openstack server show is formatted which makes it unreliable. Is there an API for this?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2019-12-20 17:41:17 -0500

Mahyar Sepehr gravatar image

openstack server list --name '.myvm.' -f value -c Networks | awk '{print $2}'

edit flag offensive delete link more

answered 2016-07-05 22:35:54 -0500

james-denton gravatar image

There's nothing I know of in the API that does it gracefully, but I'd love to know otherwise. Floating IPs are associated with ports, which are in turn associated with instances. You can try determining the ID of the port(s) associated with an instance ID using the following:

neutron port-list --device_id=<instanceid>

Then you can filter floating IPs by the port ID(s):

neutron floatingip-list --port-id=<portid>

You can also filter floating IPs by the fixed IP address, if you know that:

neutron floatingip-list --fixed-ip-address=<fixedip>

However, you may get duplicate responses if you have multiple instances with the same fixed IP address in different networks.

edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2016-06-14 07:36:06 -0500

Seen: 1,143 times

Last updated: Jul 05 '16