Debian Codegraph @

octavia_tempest_plugin/services/load_balancer/v2/healthmonitor_client.py

raw symbols SCIP
1 # Copyright 2018 GoDaddy
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
4 # not use this file except in compliance with the License. You may obtain
5 # a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 # License for the specific language governing permissions and limitations
13 # under the License.
14
15 from tempest import config
16
17 from octavia_tempest_plugin.common.decorators import skip_if_not_implemented
18 from octavia_tempest_plugin.services.load_balancer.v2 import base_client
19
20 CONF = config.CONF
21 Unset = base_client.Unset
22
23
24 class HealthMonitorClient(base_client.BaseLBaaSClient):
25
26 root_tag = 'healthmonitor'
27 list_root_tag = 'healthmonitors'
28 resource_name = 'healthmonitor'
29
30 @skip_if_not_implemented
31 def create_healthmonitor(self, pool_id, type, delay, timeout, max_retries,
32 max_retries_down=Unset, name=Unset, tags=Unset,
33 http_method=Unset, url_path=Unset,
34 expected_codes=Unset, admin_state_up=Unset,
35 return_object_only=True):
36 """Create a healthmonitor.
37
38 :param pool_id: The ID of the pool.
39 :param type: The type of health monitor.
40 :param delay: The time, in seconds, between sending probes to members.
41 :param timeout: The maximum time, in seconds, that a monitor waits to
42 connect before it times out.
43 :param max_retries: The number of successful checks before changing the
44 operating status of the member to ONLINE.
45 :param max_retries_down: The number of allowed check failures before
46 changing the operating status of the member to
47 ERROR.
48 :param name: Human-readable name of the resource.
49 :param tags: Human-readable tags of the resource.
50 :param http_method: The HTTP method that the health monitor uses for
51 requests.
52 :param url_path: The HTTP URL path of the request sent by the monitor
53 to test the health of a backend member.
54 :param expected_codes: The list of HTTP status codes expected in
55 response from the member to declare it healthy.
56 :param admin_state_up: The administrative state of the resource, which
57 is up (true) or down (false).
58 :param return_object_only: If True, the response returns the object
59 inside the root tag. False returns the full
60 response from the API.
61 :raises AssertionError: if the expected_code isn't a valid http success
62 response code
63 :raises BadRequest: If a 400 response code is received
64 :raises Conflict: If a 409 response code is received
65 :raises Forbidden: If a 403 response code is received
66 :raises Gone: If a 410 response code is received
67 :raises InvalidContentType: If a 415 response code is received
68 :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
69 :raises InvalidHttpSuccessCode: if the read code isn't an expected
70 http success code
71 :raises NotFound: If a 404 response code is received
72 :raises NotImplemented: If a 501 response code is received
73 :raises OverLimit: If a 413 response code is received and over_limit is
74 not in the response body
75 :raises RateLimitExceeded: If a 413 response code is received and
76 over_limit is in the response body
77 :raises ServerFault: If a 500 response code is received
78 :raises Unauthorized: If a 401 response code is received
79 :raises UnexpectedContentType: If the content-type of the response
80 isn't an expect type
81 :raises UnexpectedResponseCode: If a response code above 400 is
82 received and it doesn't fall into any
83 of the handled checks
84 :raises UnprocessableEntity: If a 422 response code is received and
85 couldn't be parsed
86 :returns: A healthmonitor object.
87 """
88 kwargs = {arg: value for arg, value in locals().items()
89 if arg != 'self' and value is not Unset}
90 return self._create_object(**kwargs)
91
92 @skip_if_not_implemented
93 def show_healthmonitor(self, healthmonitor_id, query_params=None,
94 return_object_only=True):
95 """Get healthmonitor details.
96
97 :param healthmonitor_id: The healthmonitor ID to query.
98 :param query_params: The optional query parameters to append to the
99 request. Ex. fields=id&fields=name
100 :param return_object_only: If True, the response returns the object
101 inside the root tag. False returns the full
102 response from the API.
103 :raises AssertionError: if the expected_code isn't a valid http success
104 response code
105 :raises BadRequest: If a 400 response code is received
106 :raises Conflict: If a 409 response code is received
107 :raises Forbidden: If a 403 response code is received
108 :raises Gone: If a 410 response code is received
109 :raises InvalidContentType: If a 415 response code is received
110 :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
111 :raises InvalidHttpSuccessCode: if the read code isn't an expected
112 http success code
113 :raises NotFound: If a 404 response code is received
114 :raises NotImplemented: If a 501 response code is received
115 :raises OverLimit: If a 413 response code is received and over_limit is
116 not in the response body
117 :raises RateLimitExceeded: If a 413 response code is received and
118 over_limit is in the response body
119 :raises ServerFault: If a 500 response code is received
120 :raises Unauthorized: If a 401 response code is received
121 :raises UnexpectedContentType: If the content-type of the response
122 isn't an expect type
123 :raises UnexpectedResponseCode: If a response code above 400 is
124 received and it doesn't fall into any
125 of the handled checks
126 :raises UnprocessableEntity: If a 422 response code is received and
127 couldn't be parsed
128 :returns: A healthmonitor object.
129 """
130 return self._show_object(obj_id=healthmonitor_id,
131 query_params=query_params,
132 return_object_only=return_object_only)
133
134 @skip_if_not_implemented
135 def list_healthmonitors(self, query_params=None, return_object_only=True):
136 """Get a list of healthmonitor objects.
137
138 :param query_params: The optional query parameters to append to the
139 request. Ex. fields=id&fields=name
140 :param return_object_only: If True, the response returns the object
141 inside the root tag. False returns the full
142 response from the API.
143 :raises AssertionError: if the expected_code isn't a valid http success
144 response code
145 :raises BadRequest: If a 400 response code is received
146 :raises Conflict: If a 409 response code is received
147 :raises Forbidden: If a 403 response code is received
148 :raises Gone: If a 410 response code is received
149 :raises InvalidContentType: If a 415 response code is received
150 :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
151 :raises InvalidHttpSuccessCode: if the read code isn't an expected
152 http success code
153 :raises NotFound: If a 404 response code is received
154 :raises NotImplemented: If a 501 response code is received
155 :raises OverLimit: If a 413 response code is received and over_limit is
156 not in the response body
157 :raises RateLimitExceeded: If a 413 response code is received and
158 over_limit is in the response body
159 :raises ServerFault: If a 500 response code is received
160 :raises Unauthorized: If a 401 response code is received
161 :raises UnexpectedContentType: If the content-type of the response
162 isn't an expect type
163 :raises UnexpectedResponseCode: If a response code above 400 is
164 received and it doesn't fall into any
165 of the handled checks
166 :raises UnprocessableEntity: If a 422 response code is received and
167 couldn't be parsed
168 :returns: A list of healthmonitor objects.
169 """
170 return self._list_objects(query_params=query_params,
171 return_object_only=return_object_only)
172
173 @skip_if_not_implemented
174 def update_healthmonitor(self, healthmonitor_id, delay=Unset,
175 timeout=Unset, max_retries=Unset,
176 max_retries_down=Unset, name=Unset, tags=Unset,
177 http_method=Unset, url_path=Unset,
178 expected_codes=Unset, admin_state_up=Unset,
179 return_object_only=True):
180 """Update a healthmonitor.
181
182 :param healthmonitor_id: The healthmonitor ID to update.
183 :param delay: The time, in seconds, between sending probes to members.
184 :param timeout: The maximum time, in seconds, that a monitor waits to
185 connect before it times out.
186 :param max_retries: The number of successful checks before changing the
187 operating status of the member to ONLINE.
188 :param max_retries_down: The number of allowed check failures before
189 changing the operating status of the member to
190 ERROR.
191 :param name: Human-readable name of the resource.
192 :param tags: Human-readable tags of the resource.
193 :param http_method: The HTTP method that the health monitor uses for
194 requests.
195 :param url_path: The HTTP URL path of the request sent by the monitor
196 to test the health of a backend member.
197 :param expected_codes: The list of HTTP status codes expected in
198 response from the member to declare it healthy.
199 :param admin_state_up: The administrative state of the resource, which
200 is up (true) or down (false).
201 :param return_object_only: If True, the response returns the object
202 inside the root tag. False returns the full
203 response from the API.
204 :raises AssertionError: if the expected_code isn't a valid http success
205 response code
206 :raises BadRequest: If a 400 response code is received
207 :raises Conflict: If a 409 response code is received
208 :raises Forbidden: If a 403 response code is received
209 :raises Gone: If a 410 response code is received
210 :raises InvalidContentType: If a 415 response code is received
211 :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
212 :raises InvalidHttpSuccessCode: if the read code isn't an expected
213 http success code
214 :raises NotFound: If a 404 response code is received
215 :raises NotImplemented: If a 501 response code is received
216 :raises OverLimit: If a 413 response code is received and over_limit is
217 not in the response body
218 :raises RateLimitExceeded: If a 413 response code is received and
219 over_limit is in the response body
220 :raises ServerFault: If a 500 response code is received
221 :raises Unauthorized: If a 401 response code is received
222 :raises UnexpectedContentType: If the content-type of the response
223 isn't an expect type
224 :raises UnexpectedResponseCode: If a response code above 400 is
225 received and it doesn't fall into any
226 of the handled checks
227 :raises UnprocessableEntity: If a 422 response code is received and
228 couldn't be parsed
229 :returns: A healthmonitor object.
230 """
231 kwargs = {arg: value for arg, value in locals().items()
232 if arg != 'self' and value is not Unset}
233 kwargs['obj_id'] = kwargs.pop('healthmonitor_id')
234 return self._update_object(**kwargs)
235
236 @skip_if_not_implemented
237 def delete_healthmonitor(self, healthmonitor_id, ignore_errors=False):
238 """Delete a healthmonitor.
239
240 :param healthmonitor_id: The healthmonitor ID to delete.
241 :param ignore_errors: True if errors should be ignored.
242 :raises AssertionError: if the expected_code isn't a valid http success
243 response code
244 :raises BadRequest: If a 400 response code is received
245 :raises Conflict: If a 409 response code is received
246 :raises Forbidden: If a 403 response code is received
247 :raises Gone: If a 410 response code is received
248 :raises InvalidContentType: If a 415 response code is received
249 :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
250 :raises InvalidHttpSuccessCode: if the read code isn't an expected
251 http success code
252 :raises NotFound: If a 404 response code is received
253 :raises NotImplemented: If a 501 response code is received
254 :raises OverLimit: If a 413 response code is received and over_limit is
255 not in the response body
256 :raises RateLimitExceeded: If a 413 response code is received and
257 over_limit is in the response body
258 :raises ServerFault: If a 500 response code is received
259 :raises Unauthorized: If a 401 response code is received
260 :raises UnexpectedContentType: If the content-type of the response
261 isn't an expect type
262 :raises UnexpectedResponseCode: If a response code above 400 is
263 received and it doesn't fall into any
264 of the handled checks
265 :raises UnprocessableEntity: If a 422 response code is received and
266 couldn't be parsed
267 :returns: None if ignore_errors is True, the response status code
268 if not.
269 """
270 return self._delete_obj(obj_id=healthmonitor_id,
271 ignore_errors=ignore_errors)