Add a floating IP if needed

On HP, when we launch nodes, we need them to have a floating IP for us
to be able to connect to them.

Change-Id: I5c7ad3183d0b6329e2019a2c95968fcf3984618b
This commit is contained in:
Monty Taylor 2014-09-04 15:01:44 -07:00 committed by Jeremy Stanley
parent 61675716c4
commit 111c3609a9

View File

@ -93,6 +93,12 @@ def get_public_ip(server, version=4):
for addr in server.manager.api.floating_ips.list():
if addr.instance_id == server.id:
return addr.ip
# We don't have one - so add one please
new_ip = server.manager.api.floating_ips.create()
server.add_floating_ip(new_ip)
for addr in server.manager.api.floating_ips.list():
if addr.instance_id == server.id:
return addr.ip
for addr in server.addresses.get('public', []):
if type(addr) == type(u''): # Rackspace/openstack 1.0
return addr