yakumo.neutron.v2.vpn.ipsec_site_connection

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

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

      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 IPSec site connections in
     18  Networking V2 API
     19  """
     20
     21  from yakumo import base
     22  from yakumo.constant import UNDEF
     23  from yakumo import mapper
     24  from yakumo import utils
     25
     26
     27  ATTRIBUTE_MAPPING = [
     28      ('id', 'id', mapper.Noop),
     29      ('name', 'name', mapper.Noop),
     30      ('description', 'description', mapper.Noop),
     31      ('peer_address', 'peer_address', mapper.Noop),
     32      ('peer_id', 'peer_id', mapper.Noop),
     33      ('local_ep_group_id', 'local_ep_group_id', mapper.Noop),
     34      ('peer_ep_group_id', 'peer_ep_group_id', mapper.Noop),
     35      ('peer_cidrs', 'peer_cidrs', mapper.Noop),
     36      ('route_mode', 'route_mode', mapper.Noop),
     37      ('mtu', 'mtu', mapper.Noop),
     38      ('auth_mode', 'auth_mode', mapper.Noop),
     39      ('psk', 'psk', mapper.Noop),
     40      ('initiator', 'initiator', mapper.Noop),
     41      ('ikepolicy', 'ikepolicy_id',
     42       mapper.Resource('neutron.vpn.ikepolicy')),
     43      ('ipsecpolicy', 'ipsecpolicy_id',
     44       mapper.Resource('neutron.vpn.ipsecpolicy')),
     45      ('vpnservice', 'vpnservice_id',
     46       mapper.Resource('neutron.vpn.vpnservice')),
     47      ('project', 'tenant_id', mapper.Resource('project')),
     48      ('dpd', 'dpd', mapper.Noop),
     49      ('action', 'action', mapper.Noop),
     50      ('interval', 'interval', mapper.Noop),
     51      ('timeout', 'timeout', mapper.Noop),
     52      ('is_enabled', 'admin_state_up', mapper.Noop),
     53      ('status', 'status', mapper.Noop),
     54  ]
     55
     56
     57 -class Resource(base.Resource):
     58      """Resource class for VPN IPSec site connections in Networking V2 API"""
     59
     60 -    def update(self, name=UNDEF, description=UNDEF,
     61                 peer_address=UNDEF, peer_id=UNDEF,
     62                 local_ep_group_id=UNDEF, peer_ep_group_id=UNDEF,
     63                 peer_cidrs=UNDEF, mtu=UNDEF, psk=UNDEF, initiator=UNDEF,
     64                 dpd=UNDEF, action=UNDEF, interval=UNDEF, timeout=UNDEF,
     65                 is_enabled=UNDEF):
     66
     67          """
     68          Update properties of an IPSec site connection
     69
     70          @keyword name: IPSec site connection name
     71          @type name: str
     72          @keyword description: Description
     73          @type description: str
     74          @keyword peer_address: Peer address
     75          @type peer_address: str
     76          @keyword peer_id: Peer ID
     77          @type peer_id: str
     78          @keyword local_ep_group_id: Local EP group ID
     79          @type local_ep_group_id: str
     80          @keyword peer_ep_group_id: Peer EP group ID
     81          @type peer_ep_group_id: str
     82          @keyword peer_cidrs: Peer CIDRs
     83          @type peer_cidrs: str
     84          @keyword mtu: MTU
     85          @type mtu: int
     86          @keyword psk: PSK
     87          @type psk: str
     88          @keyword initiator: Initiator
     89          @type initiator: str
     90          @keyword dpd: DPD
     91          @type dpd: str
     92          @keyword action: Action
     93          @type action: str
     94          @keyword interval: Interval
     95          @type interval: str
     96          @keyword timeout: Timeout
     97          @type timeout: int
     98          @keyword is_enabled: Whether the connection is enabled
     99          @type is_enabled: bool
    100          @rtype: None
    101          """
    102          return super(Resource, self).create(
    103              name=name,
    104              description=description,
    105              peer_address=peer_address,
    106              peer_id=peer_id,
    107              local_ep_group_id=local_ep_group_id,
    108              peer_ep_group_id=peer_ep_group_id,
    109              peer_cidrs=peer_cidrs,
    110              mtu=mtu,
    111              psk=psk,
    112              initiator=initiator,
    113              dpd=dpd,
    114              action=action,
    115              interval=interval,
    116              timeout=timeout,
    117              is_enabled=is_enabled
    118          )
    119
    120
    121 -class Manager(base.Manager):
    122      """Manager class for VPN IPSec site connections in Networking V2 API"""
    123
    124      resource_class = Resource
    125      service_type = 'network'
    126      _attr_mapping = ATTRIBUTE_MAPPING
    127      _json_resource_key = 'ipsec_site_connection'
    128      _json_resources_key = 'ipsec_site_connections'
    129      _url_resource_path = '/v2.0/vpn/ipsec-site-connections'
    130
    131 -    def create(self, name=UNDEF, description=UNDEF, peer_address=UNDEF,
    132                 peer_id=UNDEF, local_ep_group_id=UNDEF,
    133                 peer_ep_group_id=UNDEF, peer_cidrs=UNDEF,
    134                 route_mode=UNDEF, mtu=UNDEF, auth_mode=UNDEF, psk=UNDEF,
    135                 initiator=UNDEF, ikepolicy=UNDEF, ipsecpolicy=UNDEF,
    136                 vpnservice=UNDEF, project=UNDEF, dpd=UNDEF, action=UNDEF,
    137                 interval=UNDEF, timeout=UNDEF, is_enabled=UNDEF):
    138
    139          """
    140          Create an IPSec site connection
    141
    142          @keyword name: IPSec site connection name
    143          @type name: str
    144          @keyword description: Description
    145          @type description: str
    146          @keyword peer_address: Peer address
    147          @type peer_address: str
    148          @keyword peer_id: Peer ID
    149          @type peer_id: str
    150          @keyword local_ep_group_id: Local EP group ID
    151          @type local_ep_group_id: str
    152          @keyword peer_ep_group_id: Peer EP group ID
    153          @type peer_ep_group_id: str
    154          @keyword peer_cidrs: Peer CIDRs
    155          @type peer_cidrs: str
    156          @keyword route_mode: Route mode
    157          @type route_mode: str
    158          @keyword mtu: MTU
    159          @type mtu: int
    160          @keyword auth_mode: Auth mode
    161          @type auth_mode: str
    162          @keyword psk: PSK
    163          @type psk: str
    164          @keyword initiator: Initiator
    165          @type initiator: str
    166          @keyword ikepolicy: IKE policy
    167          @type ikepolicy: str
    168          @keyword ipsecpolicy: IPSec policy
    169          @type ipsecpolicy: str
    170          @keyword vpnservice: VPN service
    171          @type vpnservice: str
    172          @keyword project: Project
    173          @type project: yakumo.project.Resource
    174          @keyword dpd: DPD
    175          @type dpd: str
    176          @keyword action: Action
    177          @type action: str
    178          @keyword interval: Interval
    179          @type interval: str
    180          @keyword timeout: Timeout
    181          @type timeout: int
    182          @keyword is_enabled: Whether the connection is enabled
    183          @type is_enabled: bool
    184          @return: Created connection
    185          @rtype: yakumo.neutron.v2.vpn.ipsec_site_connection.Resource
    186          """
    187          return super(Manager, self).create(
    188              name=name,
    189              description=description,
    190              peer_address=peer_address,
    191              peer_id=peer_id,
    192              local_ep_group_id=local_ep_group_id,
    193              peer_ep_group_id=peer_ep_group_id,
    194              peer_cidrs=peer_cidrs,
    195              route_mode=route_mode,
    196              mtu=mtu,
    197              auth_mode=auth_mode,
    198              psk=psk,
    199              initiator=initiator,
    200              ikepolicy=ikepolicy,
    201              ipsecpolicy=ipsecpolicy,
    202              vpnservice=vpnservice,
    203              project=project,
    204              dpd=dpd,
    205              action=action,
    206              interval=interval,
    207              timeout=timeout,
    208              is_enabled=is_enabled
    209          )
    210