summaryrefslogtreecommitdiff
path: root/novaclient/v2/floating_ips.py
diff options
context:
space:
mode:
Diffstat (limited to 'novaclient/v2/floating_ips.py')
-rw-r--r--novaclient/v2/floating_ips.py59
1 files changed, 59 insertions, 0 deletions
diff --git a/novaclient/v2/floating_ips.py b/novaclient/v2/floating_ips.py
new file mode 100644
index 0000000..cce92da
--- /dev/null
+++ b/novaclient/v2/floating_ips.py
@@ -0,0 +1,59 @@
1# Copyright (c) 2011 X.commerce, a business unit of eBay Inc.
2# Copyright 2011 OpenStack Foundation
3# All Rights Reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may
6# not use this file except in compliance with the License. You may obtain
7# a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations
15# under the License.
16
17from novaclient import base
18
19
20class FloatingIP(base.Resource):
21 def delete(self):
22 """
23 Delete this floating IP
24 """
25 self.manager.delete(self)
26
27
28class FloatingIPManager(base.ManagerWithFind):
29 resource_class = FloatingIP
30
31 def list(self, all_tenants=False):
32 """
33 List floating IPs
34 """
35 url = '/os-floating-ips'
36 if all_tenants:
37 url += '?all_tenants=1'
38 return self._list(url, "floating_ips")
39
40 def create(self, pool=None):
41 """
42 Create (allocate) a floating IP for a tenant
43 """
44 return self._create("/os-floating-ips", {'pool': pool}, "floating_ip")
45
46 def delete(self, floating_ip):
47 """
48 Delete (deallocate) a floating IP for a tenant
49
50 :param floating_ip: The floating IP address to delete.
51 """
52 self._delete("/os-floating-ips/%s" % base.getid(floating_ip))
53
54 def get(self, floating_ip):
55 """
56 Retrieve a floating IP
57 """
58 return self._get("/os-floating-ips/%s" % base.getid(floating_ip),
59 "floating_ip")