Ask Your Question
0

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 ( http://api.openstack.org/ ) 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
0

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
0

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>

ip_here
</addfloatingip>

edit flag offensive delete link more
0

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

johngarbutt gravatar image

While not definitive, you can look at the example in devstack: https://github.com/openstack-dev/devstack/blob/master/exercises/floating_ips.sh#L165 (https://github.com/openstack-dev/devs...)

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: https://github.com/openstack/python-novaclient/blob/master/novaclient/v1_1/shell.py#L1326 (https://github.com/openstack/python-n...)

That points towards this code: https://github.com/openstack/python-novaclient/blob/master/novaclient/v1_1/servers.py#L329 (https://github.com/openstack/python-n...) 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: https://github.com/openstack/python-novaclient/blob/master/novaclient/v1_1/servers.py#L562 (https://github.com/openstack/python-n...)

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

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: 2012-10-02 08:39:53 -0500

Seen: 462 times

Last updated: Oct 02 '12