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

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