summaryrefslogtreecommitdiff
path: root/novaclient/v2/floating_ips_bulk.py
diff options
context:
space:
mode:
Diffstat (limited to 'novaclient/v2/floating_ips_bulk.py')
-rw-r--r--novaclient/v2/floating_ips_bulk.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/novaclient/v2/floating_ips_bulk.py b/novaclient/v2/floating_ips_bulk.py
new file mode 100644
index 0000000..fb59a19
--- /dev/null
+++ b/novaclient/v2/floating_ips_bulk.py
@@ -0,0 +1,58 @@
1# Copyright 2012 IBM Corp.
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16"""
17Bulk Floating IPs interface
18"""
19from novaclient import base
20
21
22class FloatingIP(base.Resource):
23 def __repr__(self):
24 return "<FloatingIP: %s>" % self.address
25
26
27class FloatingIPBulkManager(base.ManagerWithFind):
28 resource_class = FloatingIP
29
30 def list(self, host=None):
31 """
32 List all floating IPs
33 """
34 if host is None:
35 return self._list('/os-floating-ips-bulk', 'floating_ip_info')
36 else:
37 return self._list('/os-floating-ips-bulk/%s' % host,
38 'floating_ip_info')
39
40 def create(self, ip_range, pool=None, interface=None):
41 """
42 Create floating IPs by range
43 """
44 body = {"floating_ips_bulk_create": {'ip_range': ip_range}}
45 if pool is not None:
46 body['floating_ips_bulk_create']['pool'] = pool
47 if interface is not None:
48 body['floating_ips_bulk_create']['interface'] = interface
49
50 return self._create('/os-floating-ips-bulk', body,
51 'floating_ips_bulk_create')
52
53 def delete(self, ip_range):
54 """
55 Delete floating IPs by range
56 """
57 body = {"ip_range": ip_range}
58 return self._update('/os-floating-ips-bulk/delete', body)