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

Source Code for Module yakumo.neutron.v2.lb.vip

  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 virtual IPs 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      ('protocol', 'protocol', mapper.Noop), 
 31      ('address', 'address', mapper.Noop), 
 32      ('protocol_port', 'protocol_port', mapper.Noop), 
 33      ('connection_limit', 'connection_limit', mapper.Noop), 
 34      ('pool', 'pool_id', mapper.Resource('neutron.lb.pool')), 
 35      ('subnet', 'subnet_id', mapper.Resource('neutron.subnet')), 
 36      ('project', 'tenant_id', mapper.Resource('project')), 
 37      ('port', 'port_id', mapper.Resource('neutron.port')), 
 38      ('is_enabled', 'admin_state_up', mapper.Noop), 
 39      ('is_session_persistent', 'session_persistence', mapper.Noop), 
 40      ('status', 'status', mapper.Noop), 
 41  ] 
 42   
 43   
44 -class Resource(base.Resource):
45 """Resource class for LB virtual IPs in Networking V2 API""" 46
47 - def update(self, name=UNDEF, description=UNDEF, session_persistence=UNDEF, 48 connection_limit=UNDEF, is_enabled=UNDEF):
49 """ 50 Update a VIP for a LB pool 51 52 @keyword name: VIP name (str) 53 @type name: str 54 @keyword description: VIP description (str) 55 @type description: str 56 @keyword is_session_persistent: Whether session is persistent 57 @type is_session_persistent: bool 58 @keyword connection_limit: Maximum connection number 59 @type connection_limit: int 60 @keyword is_enabled: Whether the VIP is enabled 61 @type is_enabled: bool 62 @rtype: None 63 """ 64 pool = self.parent_resource 65 super(Resource, self).update( 66 name=name, 67 description=description, 68 pool=pool, 69 session_persistence=session_persistence, 70 connection_limit=connection_limit, 71 is_enabled=is_enabled)
72 73
74 -class Manager(base.SubManager):
75 """Manager class for LB virtual IPs in Networking V2 API""" 76 77 resource_class = Resource 78 service_type = 'network' 79 _attr_mapping = ATTRIBUTE_MAPPING 80 _json_resource_key = 'vip' 81 _json_resources_key = 'vips' 82 _url_resource_path = '/v2.0/lb/vips' 83
84 - def create(self, name=UNDEF, description=UNDEF, subnet=UNDEF, 85 address=UNDEF, protocol=UNDEF, protocol_port=UNDEF, 86 session_persistence=UNDEF, connection_limit=UNDEF, 87 is_enabled=UNDEF):
88 """ 89 Create a VIP for a LB pool 90 91 @keyword name: VIP name 92 :param name: str 93 @keyword description: VIP description 94 :param description: str 95 @keyword subnet: Subnet object (required) 96 :param subnet: yakumo.neutron.v2.subnet.Resource 97 @keyword address: Address 98 :param address: str 99 @keyword protocol: Protocol; 'TCP', 'HTTP', or 'HTTPS' (required) 100 :param protocol: str 101 @keyword protocol_port: Port number 102 :param protocol_port: int 103 @keyword pool: LB pool 104 :param pool: yakumo.neutron.v2.lb_pool.Resource 105 @keyword is_session_persistent: Whether the session is persistent 106 :param is_session_persistent: bool 107 @keyword connection_limit: Maximum connection number 108 :param connection_limit: int 109 @keyword is_enabled: Whether the VIP is enabled 110 :param is_enabled: bool 111 @return: Created VIP 112 @rtype: yakumo.neutron.v2.lb.vip.Resource 113 """ 114 pool = self.parent_resource 115 return super(Manager, self).create( 116 name=name, 117 description=description, 118 subnet=subnet, 119 address=address, 120 protocol=protocol, 121 protocol_port=protocol_port, 122 pool=pool, 123 session_persistence=session_persistence, 124 connection_limit=connection_limit, 125 is_enabled=is_enabled)
126
127 - def _find_gen(self, **kwargs):
128 kwargs['pool'] = self.parent_resource 129 return super(Manager, self)._find_gen(**kwargs)
130