From 111c3609a9322e5797b7b72e9bc387c6fe8a8ec1 Mon Sep 17 00:00:00 2001
From: Monty Taylor <mordred@inaugust.com>
Date: Thu, 4 Sep 2014 15:01:44 -0700
Subject: [PATCH] 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
---
 launch/utils.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/launch/utils.py b/launch/utils.py
index 0ed05c3319..a9f8d01bab 100644
--- a/launch/utils.py
+++ b/launch/utils.py
@@ -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