Ask Your Question

Associate Floating ip OpenstackSDK

asked 2016-11-02 08:17:08 -0500

ankur_tum gravatar image

updated 2016-11-04 15:51:20 -0500

rbowen gravatar image

I want to associate a floating IP to an instance using the OpenstackSDK. I went through all the network and compute Apis Documentation, but did not find the API to associate. I was able to create the floating IP using the create_ip API.

This is where I found the APIs.


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2016-11-04 17:51:14 -0500

dbaxps gravatar image


 [root@ip-192-169-142-127 api(keystone_admin)]# cat
#!/usr/bin/env python
import os

def get_keystone_creds():
    d = {}
    d['username'] = os.environ['OS_USERNAME']
    d['password'] = os.environ['OS_PASSWORD']
    d['auth_url'] = os.environ['OS_AUTH_URL']
    d['tenant_name'] = os.environ['OS_TENANT_NAME']
    return d

def get_nova_creds():
    d = {}
    d['username'] = os.environ['OS_USERNAME']
    d['api_key'] = os.environ['OS_PASSWORD']
    d['auth_url'] = os.environ['OS_AUTH_URL']
    d['project_id'] = os.environ['OS_TENANT_NAME']
    return d


[root@ip-192-169-142-127 api(keystone_admin)]# cat

#!/usr/bin/env python
import os
import time
from novaclient.v2.client import Client
from credentials import get_nova_creds

# Assign floating IP for active instance

creds = get_nova_creds()
nova = Client(**creds)
floating_ip = nova.floating_ips.create(nova.floating_ip_pools.list()[0].name)
instance = nova.servers.find(name="Ubuntu1510Devs")
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


Asked: 2016-11-02 08:17:08 -0500

Seen: 331 times

Last updated: Nov 04 '16