yakumo.neutron.v2.lbaas.load_balancer

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

# Source Code for Module yakumo.neutron.v2.lbaas.load_balancer

      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 load balancers 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      ('listeners', 'listeners',
     31       mapper.List(mapper.Resource('neutron.lbaas.listener'))),
     32      ('vip_address', 'vip_address', mapper.Noop),
     33      ('subnet', 'vip_subnet_id', mapper.Resource('neutron.subnet')),
     34      ('operating_status', 'operating_status', mapper.Noop),
     35      ('provisioning_status', 'provisioning_status', mapper.Noop),
     36      ('project', 'tenant_id', mapper.Resource('project')),
     37      ('is_enabled', 'admin_state_up', mapper.Noop),
     38  ]
     39
     40
     41 -class Resource(base.Resource):
     42      """Resource class for LBaaS load balancers in Networking V2 API"""
     43
     44 -    def update(self, name=UNDEF, description=UNDEF, is_enabled=UNDEF):
     45          """
     46          Update properties of a LBaaS listener
     47
     48          @keyword name: Listener name
     49          @type name: str
     50          @keyword description: Description
     51          @type description: str
     52          @keyword is_enabled: Whether the listener is enabled
     53          @type is_enabled: bool
     54          @rtype: None
     55          """
     56          super(Resource, self).update(
     57              name=name,
     58              description=description,
     59              is_enabled=is_enabled)
     60
     61
     62 -class Manager(base.Manager):
     63      """Manager class for LBaaS load balancers in Networking V2 API"""
     64
     65      resource_class = Resource
     66      service_type = 'network'
     67      _attr_mapping = ATTRIBUTE_MAPPING
     68      _json_resource_key = 'loadbalancer'
     69      _json_resources_key = 'loadbalancers'
     70      _url_resource_path = '/v2.0/lbaas/loadbalancers'
     71
     72 -    def create(self, name=UNDEF, description=UNDEF, project=UNDEF,
     73                 vip_subnet=UNDEF, vip_address=UNDEF, is_enabled=UNDEF,
     74                 provider=UNDEF):
     75          """
     76          Create a LBaaS listener
     77
     78          @keyword name: Listener name
     79          @type name: str
     80          @keyword description: Description
     81          @type description: str
     82          @keyword project: Project
     83          @type project: yakumo.project.Resource
     84          @keyword vip_subnet: VIP subnet
     85          @type vip_subnet: str
     86          @keyword vip_address: VIP address
     87          @type vip_address: str
     88          @keyword provider: Provider
     89          @type provider: str
     90          @keyword is_enabled: Whether the listener is enabled
     91          @type is_enabled: bool
     92          @return: Created listener
     93          @rtype: yakumo.neutron.v2.lbaas.load_balancer.Resource
     94          """
     95          return super(Manager, self).create(
     96              name=name,
     97              description=description,
     98              project=project,
     99              vip_subnet=vip_subnet,
    100              vip_address=vip_address,
    101              is_enabled=is_enabled,
    102              provider=provider)
    103