Repository: libcloud
Updated Branches:
  refs/heads/trunk 1a057c9c2 -> ac4a8c1b0


Makes the ip_pool attribute optional in the function ex_create_floating_ip. 
This is useful in case there is only one IP pool available.


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/e0cb51bc
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/e0cb51bc
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/e0cb51bc

Branch: refs/heads/trunk
Commit: e0cb51bc7127553ee831096a5ab37e86552f309b
Parents: 68c8d58
Author: marko_praprotnik <praprtm65>
Authored: Mon Mar 21 13:08:21 2016 +0100
Committer: anthony-shaw <[email protected]>
Committed: Tue Mar 22 20:56:19 2016 +1100

----------------------------------------------------------------------
 libcloud/compute/drivers/openstack.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/e0cb51bc/libcloud/compute/drivers/openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/openstack.py 
b/libcloud/compute/drivers/openstack.py
index c7df4bf..8c3bce7 100644
--- a/libcloud/compute/drivers/openstack.py
+++ b/libcloud/compute/drivers/openstack.py
@@ -2313,15 +2313,20 @@ class OpenStack_1_1_NodeDriver(OpenStackNodeDriver):
         ip_obj, = [x for x in floating_ips if x.ip_address == ip]
         return ip_obj
 
-    def ex_create_floating_ip(self, ip_pool):
+    def ex_create_floating_ip(self, ip_pool=None):
         """
-        Create new floating IP
+        Create new floating IP. The ip_pool attribute is optional only if your
+        infrastructure has only one IP pool available.
 
         :param      ip_pool: name of the floating IP pool
         :type       ip_pool: ``str``
 
         :rtype: :class:`OpenStack_1_1_FloatingIpAddress`
         """
+        if (ip_pool is None) and (len(self.ex_list_floating_ip_pools()) == 1):
+            ip_pool = self.ex_list_floating_ip_pools()[0].name
+        elif (ip_pool is None) and (len(self.ex_list_floating_ip_pools()) > 1):
+            return None
         resp = self.connection.request('/os-floating-ips',
                                        method='POST',
                                        data={'pool': ip_pool})

Reply via email to