yakumo.neutron.v2.lbaas.listener

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

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

      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 listeners 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      ('protocol_port', 'protocol_port', mapper.Noop),
     32      ('connection_limit', 'connection_limit', mapper.Noop),
     33      ('default_tls_container_ref', 'default_tls_container_ref',
     34       mapper.Noop),
     35      ('sni_container_refs', 'sni_container_refs', mapper.Noop),
     36      ('default_pool', 'default_pool_id',
     37       mapper.Resource('neutron.lbaas.pool')),
     38      ('project', 'tenant_id', mapper.Resource('project')),
     39      ('is_enabled', 'admin_state_up', mapper.Noop),
     40  ]
     41
     42
     43 -class Resource(base.Resource):
     44      """Resource class for LBaaS listeners in Networking V2 API"""
     45
     46 -    def update(self, name=UNDEF, description=UNDEF, connection_limit=UNDEF,
     47                 default_tls_container_ref=UNDEF, sni_container_refs=UNDEF,
     48                 is_enabled=UNDEF):
     49
     50          """
     51          Update a listener for LBaaS
     52
     53          @keyword name: Listener name
     54          @type name: srt
     55          @keyword description: Description
     56          @type description: str
     57          @keyword connection_limit: Maximun connection number
     58          @type connection_limit: int
     59          @keyword default_tls_container_ref: A reference to a container of
     60          TLS secrets
     61          @type default_tls_container_ref: str
     62          @keyword sni_container_refs: A list of references to TLS secrets
     63          @type sni_container_refs: [str]
     64          @keyword is_enabled: Is listener enabled
     65          @type is_enabled: bool
     66          @rtype: None
     67          """
     68          super(Resource, self).update(
     69              name=name,
     70              description=description,
     71              connection_limit=connection_limit,
     72              default_tls_container_ref=default_tls_container_ref,
     73              sni_container_refs=sni_container_refs,
     74              is_enabled=is_enabled)
     75
     76
     77 -class Manager(base.SubManager):
     78      """Manager class for LBaaS listeners in Networking V2 API"""
     79
     80      resource_class = Resource
     81      service_type = 'network'
     82      _attr_mapping = ATTRIBUTE_MAPPING
     83      _json_resource_key = 'listener'
     84      _json_resources_key = 'listeners'
     85      _url_resource_path = '/v2.0/lbaas/listeners'
     86
     87 -    def create(self, name=UNDEF, description=UNDEF, protocol=UNDEF,
     88                 protocol_port=UNDEF, connection_limit=UNDEF,
     89                 default_tls_container_ref=UNDEF, sni_container_refs=UNDEF,
     90                 project=UNDEF, is_enabled=UNDEF):
     91          """
     92          Create a listener for LBaaS
     93
     94          @keyword name: Listener name
     95          @type name: str
     96          @keyword description: Description
     97          @type description: str
     98          @keyword protocol: Protocol ('TCP', 'UDP', 'HTTP' or 'HTTPS')
     99          @type protocol: str
    100          @keyword protocol_port: Protocol port number
    101          @type protocol_port: int
    102          @keyword connection_limit: Maximun connection number
    103          @type connection_limit: int
    104          @keyword default_tls_container_ref: A reference to a container of
    105          TLS secrets
    106          @type default_tls_container_ref: str
    107          @keyword sni_container_refs: A list of references to TLS secrets
    108          @type sni_container_refs: str
    109          @keyword project: Project
    110          @type project: yakumo.project.Resource
    111          @keyword is_enabled: Whether the listner is enabled
    112          @type is_enabled: bool
    113          @return: Created listener
    114          @rtype: yakumo.neutron.v2.lbaas.listener.Resource
    115          """
    116          load_balancer = self.parent_resource
    117          return super(Manager, self).create(
    118              name=name,
    119              description=description,
    120              protocol=protocol,
    121              protocol_port=protocol_port,
    122              connection_limit=connection_limit,
    123              loadbalancer=loadbalancer,
    124              default_tls_container_ref=default_tls_container_ref,
    125              sni_container_refs=sni_container_refs,
    126              project=project,
    127              is_enabled=is_enabled)
    128