[Openstack] [openstack] Prevent floating IP reassignment

Derek Wood derek at cask.co
Wed Oct 12 22:16:34 UTC 2016


Hi,

I have a question regarding using the compute "action" API to assign a
floating IP to a server
(http://developer.openstack.org/api-ref-compute-v2.1.html#addFloatingIp).
Using the API call below [1],  I am able to successfully assign a
floating IP to a server, even if the floating IP is already assigned
to another server.  My question is, is there a way or an equivalent
API that will fail if the floating IP is already assigned to another
node?

My use-case is that I have a couple processes running in parallel,
each provisioning instances with floating ips.  They often end up
querying for the list of available floating ips around the same time,
and request the same floating ip to be assigned to different
servers... both succeed, and last one "wins".  I'd like to find an API
call that will fail instead of reassign, so I can avoid implementing
some sort of inter-process synchronization on the client side.  Any
pointers appreciated.

Thanks,
-Derek

[1] $ curl -s -v -X POST -d @addfloatingip.json -H "Content-type:
application/json" -H "X-Auth-Token: $OS_TOKEN"
https://[hostname]:8774/v2/$OS_TENANT_NAME/servers/[uuid]/action

where addfloatingip.json:
{
    "addFloatingIp": {
        "address": "[ip-address]"
    }
}

where "ip-address" is a floating ip already assigned to another instance.




More information about the Openstack mailing list