Package yakumo :: Package neutron :: Package v2 :: Package lbaas :: Module member
[hide private]
[frames] | no frames]

Source Code for Module yakumo.neutron.v2.lbaas.member

 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 LBaaS backend members 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      ('address', 'address', mapper.Noop), 
29      ('protocol_port', 'protocol_port', mapper.Noop), 
30      ('weight', 'weight', mapper.Noop), 
31      ('subnet', 'subnet_id', mapper.Resource('neutron.subnet')), 
32      ('project', 'tenant_id', mapper.Resource('project')), 
33      ('is_enabled', 'admin_state_up', mapper.Noop), 
34  ] 
35   
36   
37 -class Resource(base.Resource):
38 """Resource class for LBaaS backend members in Networking V2 API""" 39
40 - def update(self, weight=UNDEF, is_enabled=UNDEF):
41 """ 42 Update a LBaaS member for a pool 43 44 @keyword weight: Weight 45 @type weight: int 46 @keyword is_enabled: Whether the member is enabled 47 @type is_enabled: bool 48 @rtype: None 49 """ 50 super(Resource, self).update(weight=weight, 51 is_enabled=is_enabled)
52 53
54 -class Manager(base.SubManager):
55 """Manager class for LBaaS backend members in Networking V2 API""" 56 57 resource_class = Resource 58 service_type = 'network' 59 _attr_mapping = ATTRIBUTE_MAPPING 60 _json_resource_key = 'member' 61 _json_resources_key = 'members' 62 _url_resource_path = '/v2.0/lbaas/pools/%s/members' 63
64 - def create(self, address=UNDEF, port=UNDEF, weight=UNDEF, 65 is_enabled=UNDEF):
66 """ 67 Register a LBaaS member for a pool 68 69 @keyword address: IP address (required) 70 @type address: str 71 @keyword port: Protocol port (required) 72 @type port: int 73 @keyword weight: Member weight 74 @type weight: int 75 @keyword project: Project 76 @type project: yakumo.project.Resource 77 @keyword is_enabled: Whether the member is enabled 78 @type is_enabled: bool 79 @return: Registered member 80 @rtype: yakumo.neutron.v2.lbaas.member.Resource 81 """ 82 return super(Manager, self).create(address=address, 83 port=port, 84 weight=weight, 85 project=project, 86 is_enabled=is_enabled)
87