yakumo.neutron.v2.lb.health_monitor

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

# Source Code for Module yakumo.neutron.v2.lb.health_monitor

      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 Health Monitors 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      ('is_enabled', 'admin_state_up', mapper.Noop),
     30      ('pools', 'pools',
     31       mapper.List(mapper.Resource('neutron.lb.pool'))),
     32      ('type', 'type', mapper.Noop),
     33      ('http_method', 'http_method', mapper.Noop),
     34      ('url_path', 'url_path', mapper.Noop),
     35      ('expected_codes', 'expected_codes', mapper.Noop),
     36      ('delay', 'delay', mapper.Noop),
     37      ('timeout', 'timeout', mapper.Noop),
     38      ('max_retries', 'max_retries', mapper.Noop),
     39  ]
     40
     41
     42 -class Resource(base.Resource):
     43      """Resource class for LB Health Monitors in Networking V2 API"""
     44
     45 -    def update(self, delay=UNDEF):
     46          """
     47          Update a LB health monitor
     48
     49          @keyword delay: Seconds to start waiting a response
     50          @type delay: int
     51          @rtype: None
     52          """
     53          super(Resource, self).update(delay=delay)
     54
     55
     56 -class Manager(base.Manager):
     57      """Manager class for LB Health Monitors in Networking V2 API"""
     58
     59      resource_class = Resource
     60      service_type = 'network'
     61      _attr_mapping = ATTRIBUTE_MAPPING
     62      _json_resource_key = 'health_monitor'
     63      _json_resources_key = 'health_monitors'
     64      _url_resource_path = '/v2.0/lb/health_monitors'
     65
     66 -    def create(self, type=UNDEF, http_method=UNDEF, url_path=UNDEF,
     67                 expected_codes=UNDEF, delay=UNDEF, timeout=UNDEF,
     68                 max_retries=UNDEF, is_enabled=UNDEF):
     69          """
     70          Create a LB health monitor
     71
     72          @keyword type: Monitor type ('PING', 'TCP', 'HTTP', or 'HTTPS')
     73          @type type: str
     74          @keyword http_method: HTTP method like 'GET'
     75          @type http_method: str
     76          @keyword url_path: URL path like '/index.html'
     77          @type url_path: str
     78          @keyword expected_codes: Expected HTTP response code list separated
     79          with comma
     80          @type expected_codes: str
     81          @keyword delay: Seconds to start waiting a response
     82          @type delay: int
     83          @keyword timeout: Maximum seconds to wait a response
     84          @type timeout: int
     85          @keyword max_retries: Number of allowed connection failures (up to 10)
     86          @type max_retries: int
     87          @keyword is_enabled: Monitor is enabled
     88          @type is_enabled: bool
     89          @return: Created monitor
     90          @rtype: yakumo.neutron.v2.lb.health_monitor.Resource
     91          """
     92          return super(Manager, self).create(type=type,
     93                                             http_method=http_method,
     94                                             url_path=url_path,
     95                                             expected_codes=expected_codes,
     96                                             delay=delay,
     97                                             timeout=timeout,
     98                                             max_retries=max_retries,
     99                                             is_enabled=is_enabled)
    100