[Openstack] Compute API question - public vs private addresses

marios@redhat.com mandreou at redhat.com
Wed Jun 13 08:52:19 UTC 2012


Hi,

I'm working on the Openstack driver for Deltacloud
(http://deltacloud.apache.org/) and I've come across an Openstack
compute API issue that I hope someone may be able to help with.

I'm having some trouble determining the 'public' IP address of a created
server using the API. It seems that all addresses are labelled as
'private'... e.g.:

#<Net::HTTPOK 200 OK readbody=true>
(rdb:1) response.body
"{\"server\": {\"status\": \"ACTIVE\", \"updated\":
\"2012-05-28T10:20:17Z\",
8<---SNIP--->8

 {\"private\": [{\"version\": 4, \"addr\": \"10.6.228.27\"},
{\"version\": 4, \"addr\": \"15.185.163.73\"}]},

8<---SNIP--->8

Even after allocating and attaching a floating 'ip':

#<Net::HTTPOK 200 OK readbody=true>
(rdb:1) response.body
"{\"server\": {\"status\": \"ACTIVE\", \"updated\": \"2012-05-28T10:20:17Z\"
8<---SNIP--->8

\"private\": [{\"version\": 4, \"addr\": \"10.6.228.27\"}, {\"version\":
4, \"addr\": \"15.185.163.73\"}, {\"version\": 4, \"addr\":
\"15.185.168.139\"}]}

8<---SNIP--->8

The above requests/responses are talking to the Openstack installation @
hpcloud ('diablo' i believe). However, seeing a related question on
launchpad.net:
"https://answers.launchpad.net/nova/+question/185110" it appears this
isn't an HP-cloud specific issue.

Given that there is no way for me currently to create/manage networks
via the API in order to correctly assign the 'public' IP(s) to a network
labelled 'public' (e.g. HP doesn't expose the quantum API - though
looking at quantum I can't see how to place IP addresses in a specific
network anyway), how can I differentiate between the public and private
IPs of my Servers? One way I could do this is pattern matching on
10.0.0.0/8 192.168.0.0/16, 172.16.0.0/12 - but this seems 'messy'.

Is it safe to assume that the returned addresses are always in the order
"private first and then public"? The ruby bindings 'ruby-openstack'
(https://github.com/ruby-openstack/ruby-openstack) and the hp-cloud
specific 'hp fog'
(https://docs.hpcloud.com/sites/default/files/downloads/hpfog_2.tar)
both do this: they 'grab' the first returned address as 'private' and
everything else is 'public'.

I don't think this is a very safe way of determining the addresses; I
plan to change the behaviour of the ruby-openstack gem to use 'pattern
matching' on the private/reserved address space as imo that is the
lesser of the two evils (vs just grabbing the first address). Thanks for
your time and thoughts,

marios




More information about the Openstack mailing list