yakumo.nova.v2.fixed_ip

Package yakumo :: Package nova :: Package v2 :: Module fixed_ip |
[hide private]
[frames] | no frames]

# Source Code for Module yakumo.nova.v2.fixed_ip

     1  # Copyright 2014-2017 by Akira Yoshiyama <akirayoshiyama@gmail.com>.
     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  """
    17  Resource class and its manager for fixed IPs in Compute API v2
    18  """
    19
    20  from yakumo import base
    21  from yakumo import mapper
    22
    23
    24  ATTRIBUTE_MAPPING = [
    25      ('ip', '', mapper.Noop),
    26  ]
    27
    28
    29 -class Resource(base.Resource):
    30      """Resource class for fixed IPs in Compute API v2"""
    31
    32
    33 -class Manager(base.Manager):
    34      """Manager class for fixed IPs in Compute API v2"""
    35
    36      resource_class = Resource
    37      service_type = 'compute'
    38      _attr_mapping = ATTRIBUTE_MAPPING
    39      _hidden_methods = ["create", "list", "update"]
    40      _id_attr = 'ip'
    41      _json_resource_key = 'fixed_ip'
    42      _url_resource_path = '/os-fixed-ips'
    43
    44 -    def get(self, ip=None):
    45          """
    46          Get information for fixed IP
    47
    48          @keyword ip: Fixed IP (required)
    49          @type ip: str
    50          @return: Information of the fixed IP
    51          @rtype: str
    52          """
    53          ret = self._http.get(self._url_resource_path, ip)
    54          return ret.get('fixed_ip')
    55
    56 -    def reserve(self, ip=None):
    57          """
    58          Reserve a fixed IP
    59
    60          @keyword ip: Fixed IP (required)
    61          @type ip: str
    62          @rtype: None
    63          """
    64          self._http.post(self._url_resource_path, ip, 'action',
    65                          data=dict(reserve=None))
    66
    67 -    def unreserve(self, ip=None):
    68          """
    69          Release a fixed IP
    70
    71          @keyword ip: Fixed IP (required)
    72          @type ip: str
    73          @rtype: None
    74          """
    75          self._http.post(self._url_resource_path, ip, 'action',
    76                          data=dict(unreserve=None))
    77