Ask Your Question

Assign floating IP to instance through REST API

asked 2012-10-02 08:39:53 -0500

andrey-sereda-kharkiv gravatar image

Hello All!

I've spent last 2 days trying to find a simple solution for the following problem: how could I assign floating IP I have created to the running instance on OpenStack through REST API? I can do this through web ui (dashboard) or through nova tool, but I need it through REST API. I have been using this page ( ) and I was able to find how to list floating ips, allocate new or deallocate existing, but unfortunatelly it does not answer my question.

Many thanks for your help!

edit retag flag offensive close merge delete

3 answers

Sort by ยป oldest newest most voted

answered 2012-10-02 11:25:16 -0500

johngarbutt gravatar image

While not definitive, you can look at the example in devstack: (

if you try that command with --debug it will give you all the raw requests that it made.

Looking at the code, you can see the floating ip call here: (

That points towards this code: ( def add_floating_ip(self, server, address): """ Add a floating ip to an instance :param server: The :class: Server (or its ID) to add an IP to. :param address: The FloatingIP or string floating address to add. """ address = address.ip if hasattr(address, 'ip') else address self._action('addFloatingIp', server, {'address': address})

It can be compared to the ones that are better documented: (

Looks like the doc should say something like: v2/{tenant_id}/servers/{server_id}/action and specify the addFloatingIp action

edit flag offensive delete link more

answered 2012-10-02 12:19:17 -0500

andrey-sereda-kharkiv gravatar image

Hi John, thanks a lot, it worked brilliantly!

POST to v2/{tenant_id}/servers/{server_id}/action

XML: <addfloatingip>


edit flag offensive delete link more

answered 2012-10-02 12:20:11 -0500

andrey-sereda-kharkiv gravatar image

Thanks John Garbutt, that solved my question.

edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2012-10-02 08:39:53 -0500

Seen: 636 times

Last updated: Oct 02 '12