Ask Your Question

Openstack instance ip_address

asked 2019-01-12 06:33:49 -0600

najeh gravatar image

How can i get the fixed ip_address of an openstcak instance using python sdk ?

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2019-01-12 08:07:09 -0600

updated 2019-01-15 07:52:51 -0600

find_server as documented in the openstacksdk API reference.

EDIT: find_server() returns a server object that only has the links populated. After this, you use get_server() to get all the details.

import openstack;

conn = openstack.connect(

server = conn.compute.find_server(YOUR SERVER NAME)
server = conn.compute.get_server(server)

for addrinfo in server.addresses['private']:
     print("{} ipv{} address {}\n".format(addrinfo['OS-EXT-IPS:type'],addrinfo['version'],addrinfo['addr']))

I get the following result, which includes both static and floating IPs:

openstack.compute.v2.server.Server(OS-EXT-STS:task_state=None, addresses={u'private': [{u'OS-EXT-IPS-MAC:mac_addr': u'fa:16:3e:47:41:56', u'version': 4, u'addr': u'', u'OS-EXT-IPS:type': u'fixed'}, {u'OS-EXT-IPS-MAC:mac_addr': u'fa:16:3e:47:41:56', u'version': 4, u'addr': u'', u'OS-EXT-IPS:type': u'floating'}]}, ....
fixed ipv4 address

floating ipv4 address
edit flag offensive delete link more


find_server display all information about the server but i need exactly the hostname of the instance "192.168.x.x".

how can i get it?

najeh gravatar imagenajeh ( 2019-01-13 06:06:59 -0600 )edit

As far as I understand it, it's a field in the Server object.

Bernd Bausch gravatar imageBernd Bausch ( 2019-01-13 07:58:17 -0600 )edit

Instructions how to set that field when launching an instance. Reading the field should not be harder.

Bernd Bausch gravatar imageBernd Bausch ( 2019-01-13 08:01:54 -0600 )edit

"opensttack server list" display like the table that contain all server details.I need the ip_address associated to networks for each instance. How can i get it ?


ID |Name |Status| Networks| Image


najeh gravatar imagenajeh ( 2019-01-14 05:35:36 -0600 )edit

I have never tried it, but why don’t you just print the server object returned by find_server() to find out?

Bernd Bausch gravatar imageBernd Bausch ( 2019-01-14 08:09:59 -0600 )edit

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


Asked: 2019-01-12 06:33:49 -0600

Seen: 39 times

Last updated: Jan 15