简体   繁体   中英

How to get associated ip address in openstack instance

I am trying to setup a consul server in an openstack cluster. I have the server provisioned and have associated an IP with the server that is accessible from vagrants on developer machines.

I am able to join the server from a local vagrant if I use the -advertise flag on the consul agent -server command and use the floating ip I set. However, I am provisioning the server with salt and need to the machine to be able to determine that IP automatically.

By default, the server is using its bind address which is set to its 10.xxx local IP. That local IP is the only one I seem to be able to easily determine.

Is there a way to get an instance's floating ip(s)?

Bonus points: Is there a way to get an instances name?

The information you are looking for is available to an instance using the Openstack metadata service. It is basically a REST API that an instance can hit to get information specific to this instance. See more information here:

http://docs.openstack.org/grizzly/openstack-compute/admin/content/metadata-service.html

You should be able to get both the instance name and its floating ip (look for "public-ipv4")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM