pythonopenstackopenstack-python-api

Python-openstackclient: Available_floating_ip no longer works; what replacement?


In the past I used available_floating_ip to create a new floating ip and attach it to an instance or use an existing non-attached floating ip and attach it to an instance.

For some reason the latter no longer works now (might be an update?). When a non-attached floating ip exists, available_floating_ip(network, server) returns the ip correctly, but doesn't attach it anymore to the server.

I filed a bug report, but am simultaneously looking for an alternative solution. So I was looking for an option to add a floating ip manually to a server. To my surprise I could find no such method in connection and in the compute REST API I only saw the deprecated add floating ip.

What should I use to add my floating_ip to the server?


Solution

  • conn = create_connection(...)
    server = create_server(...)
    
    If you have only one single external network:
    conn.add_auto_ip(server)
    
    float_ip = conn.available_floating_ip("Network...", server).floating_ip_address
    conn.add_ip_list(server, float_ip)
    
    While using multiple external networks:
    conn.compute.add_floating_ip_to_server(server, float_ip)