diff options
| author | Jenkins <jenkins@review.openstack.org> | 2017-04-17 21:14:05 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2017-04-17 21:14:05 +0000 |
| commit | b0ce95745db6c83bec7db45fdf7053fafe286dce (patch) | |
| tree | 822450afd4f3796f71b912134a92a8120a838010 /openstackclient/api | |
| parent | 18206a9224bd9f25c0a02498d6562efa6ee31c1b (diff) | |
| parent | e6ea45b2833fdd57a8011154aec5c1f6b00f44ca (diff) | |
| download | python-openstackclient-b0ce95745db6c83bec7db45fdf7053fafe286dce.tar.gz | |
Merge "Low-level Compute v2 API: floating ip"
Diffstat (limited to 'openstackclient/api')
| -rw-r--r-- | openstackclient/api/compute_v2.py | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/openstackclient/api/compute_v2.py b/openstackclient/api/compute_v2.py index 065121fc..181522e4 100644 --- a/openstackclient/api/compute_v2.py +++ b/openstackclient/api/compute_v2.py @@ -93,6 +93,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( |
