yakumo.neutron.v2.vpn.ike_policy

Package yakumo :: Package neutron :: Package v2 :: Package vpn :: Module ike_policy |
[hide private]
[frames] | no frames]

# Source Code for Module yakumo.neutron.v2.vpn.ike_policy

      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 VPN IKE policies in Networking V2 API
     18  """
     19
     20  from yakumo import base
     21  from yakumo.constant import UNDEF
     22  from yakumo import mapper
     23  from yakumo import utils
     24
     25
     26  ATTRIBUTE_MAPPING = [
     27      ('id', 'id', mapper.Noop),
     28      ('name', 'name', mapper.Noop),
     29      ('description', 'description', mapper.Noop),
     30      ('auth_algorithm', 'auth_algorithm', mapper.Noop),
     31      ('encryption_algorithm', 'encryption_algorithm', mapper.Noop),
     32      ('pfs', 'pfs', mapper.Noop),
     33      ('phase1_negotiation_mode', 'phase1_negotiation_mode', mapper.Noop),
     34      ('lifetime', 'lifetime', mapper.Noop),
     35      ('ike_version', 'ike_version', mapper.Noop),
     36      ('project', 'tenant_id', mapper.Resource('project')),
     37  ]
     38
     39
     40 -class Resource(base.Resource):
     41      """Resource class for VPN IKE policies in Networking V2 API"""
     42
     43 -    def update(self, name=UNDEF, description=UNDEF, auth_algorithm=UNDEF,
     44                 encryption_algorithm=UNDEF, pfs=UNDEF,
     45                 phase1_negotiation_mode=UNDEF, lifetime=UNDEF,
     46                 ike_version=UNDEF, project=UNDEF):
     47          """
     48          Update an IKE policy
     49
     50          @keyword name: IKE policy name
     51          @type name: str
     52          @keyword description: Description
     53          @type description: str
     54          @keyword auth_algorithm: Auth algorithm; only 'sha1'
     55          @type auth_algorithm: str
     56          @keyword encryption_algorithm: Encryption algorithm
     57          ('3des', 'aes-128', 'aes-192', ...)
     58          @type encryption_algorithm: str
     59          @keyword pfs: Perfect forward secrecy
     60          ('Group2', 'Group5', 'Group14', ...)
     61          @type pfs: str
     62          @keyword phase1_negotiation_mode: IKE mode; only 'main'
     63          @type phase1_negotiation_mode: str
     64          @keyword lifetime: Life time; e.q.'3600seconds'
     65          @type lifetime: str
     66          @keyword ike_version: IKE version; 'v1' or 'v2'
     67          @type ike_version: str
     68          @keyword project: Project
     69          @type project: yakumo.project.Resource
     70          @rtype: None
     71          """
     72          super(Resource, self).update(
     73              name=name,
     74              description=description,
     75              auth_algorithm=auth_algorithm,
     76              encryption_algorithm=encryption_algorithm,
     77              pfs=pfs,
     78              phase1_negotiation_mode=phase1_negotiation_mode,
     79              lifetime=lifetime,
     80              ike_version=ike_version,
     81              project=project)
     82
     83
     84 -class Manager(base.Manager):
     85      """Manager class for VPN IKE policies in Networking V2 API"""
     86
     87      resource_class = Resource
     88      service_type = 'network'
     89      _attr_mapping = ATTRIBUTE_MAPPING
     90      _json_resource_key = 'ike_policy'
     91      _json_resources_key = 'ike_policies'
     92      _url_resource_path = '/v2.0/vpn/ike_policies'
     93
     94 -    def create(self, name=UNDEF, description=UNDEF, auth_algorithm=UNDEF,
     95                 encryption_algorithm=UNDEF, pfs=UNDEF,
     96                 phase1_negotiation_mode=UNDEF, lifetime=UNDEF,
     97                 ike_version=UNDEF, project=UNDEF):
     98          """
     99          Create an IKE policy
    100
    101          @keyword name: IKE policy name
    102          @type name: str
    103          @keyword description: Description
    104          @type description: str
    105          @keyword auth_algorithm: Auth algorithm; only 'sha1'
    106          @type auth_algorithm: str
    107          @keyword encryption_algorithm: Encryption algorithm
    108          ('3des', 'aes-128', 'aes-192', ...)
    109          @type encryption_algorithm: str
    110          @keyword pfs: Perfect forward secrecy
    111          ('Group2', 'Group5', 'Group14', ...)
    112          @type pfs: str
    113          @keyword phase1_negotiation_mode: IKE mode; only 'main'
    114          @type phase1_negotiation_mode: str
    115          @keyword lifetime: Life time; e.q.'3600seconds'
    116          @type lifetime: str
    117          @keyword ike_version: IKE version; 'v1' or 'v2'
    118          @type ike_version: str
    119          @keyword project: Project object
    120          @type project: yakumo.project.Resource
    121          @return: Created policy
    122          @rtype: yakumo.neutron.v2.vpn.ike_policy.Resource
    123          """
    124          return super(Manager, self).create(
    125              name=name,
    126              description=description,
    127              auth_algorithm=auth_algorithm,
    128              encryption_algorithm=encryption_algorithm,
    129              pfs=pfs,
    130              phase1_negotiation_mode=phase1_negotiation_mode,
    131              lifetime=lifetime,
    132              ike_version=ike_version,
    133              project=project)
    134