summaryrefslogtreecommitdiff
path: root/openstackclient/api
diff options
context:
space:
mode:
authorDean Troyer <dtroyer@gmail.com>2017-04-08 11:17:30 -0500
committerDean Troyer <dtroyer@gmail.com>2017-04-11 02:10:26 -0500
commite6ea45b2833fdd57a8011154aec5c1f6b00f44ca (patch)
treec5b11b963ec22c5d58db8999c476f4c2abd70091 /openstackclient/api
parent4289ddd47a9c92eb3033eccf39966915caae05db (diff)
downloadpython-openstackclient-e6ea45b2833fdd57a8011154aec5c1f6b00f44ca.tar.gz
Low-level Compute v2 API: floating ip
api.compute.APIv2 floating ip functions. novaclient 8.0 is now released without support for the previously deprecated nova-net functions, so include a new low-level REST implementation of the removed APIs. Change-Id: Ic461b8d15e072e0534dcd73fff6857581d83c89b
Diffstat (limited to 'openstackclient/api')
-rw-r--r--openstackclient/api/compute_v2.py82
1 files changed, 82 insertions, 0 deletions
diff --git a/openstackclient/api/compute_v2.py b/openstackclient/api/compute_v2.py
index 3bf3a0d8..20062a2f 100644
--- a/openstackclient/api/compute_v2.py
+++ b/openstackclient/api/compute_v2.py
@@ -64,6 +64,88 @@ class APIv2(api.BaseAPI):
return ret
+ # Flaoting IPs
+
+ def floating_ip_create(
+ self,
+ pool=None,
+ ):
+ """Create a new floating ip
+
+ https://developer.openstack.org/api-ref/compute/#create-allocate-floating-ip-address
+
+ :param pool: Name of floating IP pool
+ """
+
+ url = "/os-floating-ips"
+
+ try:
+ return self.create(
+ url,
+ json={'pool': pool},
+ )['floating_ip']
+ except (
+ ksa_exceptions.NotFound,
+ ksa_exceptions.BadRequest,
+ ):
+ msg = _("%s not found") % pool
+ raise exceptions.NotFound(msg)
+
+ def floating_ip_delete(
+ self,
+ floating_ip_id=None,
+ ):
+ """Delete a floating IP
+
+ https://developer.openstack.org/api-ref/compute/#delete-deallocate-floating-ip-address
+
+ :param string security_group:
+ Floating IP ID
+ """
+
+ url = "/os-floating-ips"
+
+ if floating_ip_id is not None:
+ return self.delete('/%s/%s' % (url, floating_ip_id))
+
+ return None
+
+ def floating_ip_find(
+ self,
+ floating_ip=None,
+ ):
+ """Return a security group given name or ID
+
+ https://developer.openstack.org/api-ref/compute/#list-floating-ip-addresses
+
+ :param string floating_ip:
+ Floating IP address
+ :returns: A dict of the floating IP attributes
+ """
+
+ url = "/os-floating-ips"
+
+ return self.find(
+ url,
+ attr='ip',
+ value=floating_ip,
+ )
+
+ def floating_ip_list(
+ self,
+ ):
+ """Get floating IPs
+
+ https://developer.openstack.org/api-ref/compute/#show-floating-ip-address-details
+
+ :returns:
+ list of security groups names
+ """
+
+ url = "/os-floating-ips"
+
+ return self.list(url)["floating_ips"]
+
# Security Groups
def security_group_create(