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

Source Code for Module yakumo.neutron.v2.vpn.service

 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 services 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      ('router', 'router_id', mapper.Resource('neutron.router')), 
31      ('subnet', 'subnet_id', mapper.Resource('neutron.subnet')), 
32      ('project', 'tenant_id', mapper.Resource('project')), 
33      ('is_enabled', 'admin_state_up', mapper.Noop), 
34      ('status', 'status', mapper.Noop), 
35  ] 
36   
37   
38 -class Resource(base.Resource):
39 """Resource class for VPN services in Networking V2 API""" 40
41 - def update(self, name=UNDEF, description=UNDEF, router=UNDEF, 42 subnet=UNDEF, project=UNDEF, is_enabled=UNDEF):
43 """ 44 Update properties of a VPN service 45 46 @keyword name: VPN service name 47 @type name: str 48 @keyword description: Description 49 @type description: str 50 @keyword is_enabled: Is vpn enabled 51 @type is_enabled: bool 52 @rtype: None 53 """ 54 super(Resource, self).update( 55 name=name, 56 description=description, 57 is_enabled=is_enabled)
58 59
60 -class Manager(base.Manager):
61 """Manager class for VPN services in Networking V2 API""" 62 63 resource_class = Resource 64 service_type = 'network' 65 _attr_mapping = ATTRIBUTE_MAPPING 66 _json_resource_key = 'vpnservice' 67 _json_resources_key = 'vpnservices' 68 _url_resource_path = '/v2.0/vpn/vpnservices' 69
70 - def create(self, name=UNDEF, description=UNDEF, router=UNDEF, 71 subnet=UNDEF, project=UNDEF, is_enabled=UNDEF):
72 """ 73 Create a VPN service 74 75 @keyword name: VPN name 76 @type name: str 77 @keyword description: Description 78 @type description: str 79 @keyword router: Router object 80 @type router: yakumo.neutron.v2.router.Resource 81 @keyword subnet: Subnet object 82 @type subnet: yakumo.neutron.v2.subnet.Resource 83 @keyword project: Project object 84 @type project: yakumo.project.Resource 85 @keyword is_enabled: Whether the VPN service is enabled 86 @type is_enabled: bool 87 @return: Created VPN service 88 @rtype: yakumo.neutron.v2.vpn.service.Resource 89 """ 90 return super(Manager, self).create( 91 name=name, 92 description=description, 93 router=router, 94 subnet=subnet, 95 project=project, 96 is_enabled=is_enabled)
97