~ubuntu-cloud-archive/ubuntu/precise/python-novaclient/trunk

« back to all changes in this revision

Viewing changes to novaclient/v1_1/fixed_ips.py

  • Committer: Chuck Short
  • Date: 2012-11-30 14:00:31 UTC
  • mfrom: (27.1.1 raring)
  • Revision ID: zulcss@ubuntu.com-20121130140031-zy0sdcavnt4bt41g
* New upstream release for the Ubuntu Cloud Archive.
* New upstream release. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 
2
 
 
3
# Copyright 2012 IBM
 
4
# All Rights Reserved.
 
5
#
 
6
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
7
#    not use this file except in compliance with the License. You may obtain
 
8
#    a copy of the License at
 
9
#
 
10
#         http://www.apache.org/licenses/LICENSE-2.0
 
11
#
 
12
#    Unless required by applicable law or agreed to in writing, software
 
13
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
14
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
15
#    License for the specific language governing permissions and limitations
 
16
#    under the License.
 
17
 
 
18
"""
 
19
Fixed IPs interface.
 
20
"""
 
21
 
 
22
from novaclient import base
 
23
 
 
24
 
 
25
class FixedIP(base.Resource):
 
26
    def __repr__(self):
 
27
        return "<FixedIP: %s>" % self.address
 
28
 
 
29
 
 
30
class FixedIPsManager(base.ManagerWithFind):
 
31
    resource_class = FixedIP
 
32
 
 
33
    def get(self, fixed_ip):
 
34
        """
 
35
        Show information for a Fixed IP
 
36
 
 
37
        :param fixed_ip: Fixed IP address to get info for
 
38
        """
 
39
        return self._get('/os-fixed-ips/%s' % base.getid(fixed_ip),
 
40
                         "fixed_ip")
 
41
 
 
42
    def reserve(self, fixed_ip):
 
43
        """Reserve a Fixed IP
 
44
 
 
45
        :param fixed_ip: Fixed IP address to reserve
 
46
        """
 
47
        body = {"reserve": None}
 
48
        self.api.client.post('/os-fixed-ips/%s/action' % base.getid(fixed_ip),
 
49
                             body=body)
 
50
 
 
51
    def unreserve(self, fixed_ip):
 
52
        """Unreserve a Fixed IP
 
53
 
 
54
        :param fixed_ip: Fixed IP address to unreserve
 
55
        """
 
56
        body = {"unreserve": None}
 
57
        self.api.client.post('/os-fixed-ips/%s/action' % base.getid(fixed_ip),
 
58
                             body=body)