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

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