Ask Your Question
0

Get floating ip for instance

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

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

1 answer

Sort by ยป oldest newest most voted
0

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

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

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: 2016-06-14 07:36:06 -0600

Seen: 585 times

Last updated: Jul 05 '16