yakumo.nova.v2.cloudpipe

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

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

     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 cloudpipes in Compute API v2
    18  """
    19
    20  from yakumo import base
    21  from yakumo.constant import UNDEF
    22  from yakumo import mapper
    23
    24
    25  ATTRIBUTE_MAPPING = [
    26      ('server', 'instance_id', mapper.Resource('server')),
    27      ('project', 'project_id', mapper.Resource('project')),
    28      ('internal_ip', 'internal_ip', mapper.Noop),
    29      ('public_ip', 'public_ip', mapper.Noop),
    30      ('public_port', 'public_port', mapper.Noop),
    31      ('created_at', 'created_at', mapper.Noop),
    32      ('status', 'state', mapper.Noop),
    33  ]
    34
    35
    36 -class Resource(base.Resource):
    37      """Resource class for cloudpipes in Compute API v2"""
    38
    39 -    def update(self, vpn_ip=UNDEF, vpn_port=UNDEF):
    40          """
    41          Update properties of a cloudpipe
    42
    43          @keyword vpn_ip: IP address for VPN
    44          @type vpn_ip: str
    45          @keyword vpn_port: Port number for VPN
    46          @type vpn_port: str or int
    47          @rtype: None
    48          """
    49          self._http.post(join_path(self._url_resource_path, self._id,
    50                                    "configure-project"),
    51                          data=utils.get_json_body('configure_project',
    52                                                   vpn_ip=vpn_ip,
    53                                                   vpn_port=str(vpn_port)))
    54
    55
    56 -class Manager(base.Manager):
    57      """Manager class for cloudpipes in Compute API v2"""
    58
    59      resource_class = Resource
    60      service_type = 'compute'
    61      _attr_mapping = ATTRIBUTE_MAPPING
    62      _id_attr = 'server'
    63      _json_resource_key = 'cloudpipe'
    64      _json_resources_key = 'cloudpipes'
    65      _url_resource_path = '/os-cloudpipe'
    66
    67 -    def create(self, project=UNDEF):
    68          """
    69          Create a cloudpipe
    70
    71          @keyword project: Project
    72          @type project: yakumo.project.Resource
    73          @return: Created cloudpipe
    74          @rtype: yakumo.nova.v2.cloudpipe.Resource
    75          """
    76          return super(Manager, self).create(project=project)
    77