Debian Codegraph @

octavia_tempest_plugin/services/load_balancer/v2/pool_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 PoolClient(base_client.BaseLBaaSClient):
25
26 root_tag = 'pool'
27 list_root_tag = 'pools'
28 resource_name = 'pool'
29
30 @skip_if_not_implemented
31 def create_pool(self, protocol, lb_algorithm, loadbalancer_id=Unset,
32 listener_id=Unset, name=Unset, description=Unset,
33 tags=Unset,
34 admin_state_up=Unset, session_persistence=Unset,
35 ca_tls_container_ref=Unset, crl_container_ref=Unset,
36 tls_enabled=Unset, tls_container_ref=Unset,
37 alpn_protocols=Unset, return_object_only=True):
38 """Create a pool.
39
40 :param protocol: The protocol for the resource.
41 :param lb_algorithm: The load balancing algorithm for the pool.
42 :param loadbalancer_id: The ID of the load balancer for the pool.
43 :param listener_id: The ID of the listener for the pool.
44 :param name: Human-readable name of the resource.
45 :param description: A human-readable description for the resource.
46 :param tags: A human-readable tags of the resource.
47 :param admin_state_up: The administrative state of the resource, which
48 is up (true) or down (false).
49 :param session_persistence: A JSON object specifying the session
50 persistence for the pool or null for no
51 session persistence.
52 :param ca_tls_container_ref: The key manager ref for a secret
53 containing the PEM encoded CA certificate
54 to validate pool members against.
55 :param crl_container_ref: The key manager ref for a secret containing
56 the PEM encoded CRL to use when validating
57 pool members.
58 :param tls_enabled: A boolean, True when the pool should connect to
59 members using TLS.
60 :param tls_container_ref: The key manager ref for a secret containing
61 a PKCS12 bundle with the client
62 authentication certificate and key used
63 when connecting to pool members over TLS.
64 :param alpn_protocols: A list of ALPN protocols for TLS enabled pools.
65 :param return_object_only: If True, the response returns the object
66 inside the root tag. False returns the full
67 response from the API.
68 :raises AssertionError: if the expected_code isn't a valid http success
69 response code
70 :raises BadRequest: If a 400 response code is received
71 :raises Conflict: If a 409 response code is received
72 :raises Forbidden: If a 403 response code is received
73 :raises Gone: If a 410 response code is received
74 :raises InvalidContentType: If a 415 response code is received
75 :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
76 :raises InvalidHttpSuccessCode: if the read code isn't an expected
77 http success code
78 :raises NotFound: If a 404 response code is received
79 :raises NotImplemented: If a 501 response code is received
80 :raises OverLimit: If a 413 response code is received and over_limit is
81 not in the response body
82 :raises RateLimitExceeded: If a 413 response code is received and
83 over_limit is in the response body
84 :raises ServerFault: If a 500 response code is received
85 :raises Unauthorized: If a 401 response code is received
86 :raises UnexpectedContentType: If the content-type of the response
87 isn't an expect type
88 :raises UnexpectedResponseCode: If a response code above 400 is
89 received and it doesn't fall into any
90 of the handled checks
91 :raises UnprocessableEntity: If a 422 response code is received and
92 couldn't be parsed
93 :returns: A pool object.
94 """
95 kwargs = {arg: value for arg, value in locals().items()
96 if arg != 'self' and value is not Unset}
97 return self._create_object(**kwargs)
98
99 @skip_if_not_implemented
100 def show_pool(self, pool_id, query_params=None, return_object_only=True):
101 """Get pool details.
102
103 :param pool_id: The pool ID to query.
104 :param query_params: The optional query parameters to append to the
105 request. Ex. fields=id&fields=name
106 :param return_object_only: If True, the response returns the object
107 inside the root tag. False returns the full
108 response from the API.
109 :raises AssertionError: if the expected_code isn't a valid http success
110 response code
111 :raises BadRequest: If a 400 response code is received
112 :raises Conflict: If a 409 response code is received
113 :raises Forbidden: If a 403 response code is received
114 :raises Gone: If a 410 response code is received
115 :raises InvalidContentType: If a 415 response code is received
116 :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
117 :raises InvalidHttpSuccessCode: if the read code isn't an expected
118 http success code
119 :raises NotFound: If a 404 response code is received
120 :raises NotImplemented: If a 501 response code is received
121 :raises OverLimit: If a 413 response code is received and over_limit is
122 not in the response body
123 :raises RateLimitExceeded: If a 413 response code is received and
124 over_limit is in the response body
125 :raises ServerFault: If a 500 response code is received
126 :raises Unauthorized: If a 401 response code is received
127 :raises UnexpectedContentType: If the content-type of the response
128 isn't an expect type
129 :raises UnexpectedResponseCode: If a response code above 400 is
130 received and it doesn't fall into any
131 of the handled checks
132 :raises UnprocessableEntity: If a 422 response code is received and
133 couldn't be parsed
134 :returns: A pool object.
135 """
136 return self._show_object(obj_id=pool_id,
137 query_params=query_params,
138 return_object_only=return_object_only)
139
140 @skip_if_not_implemented
141 def list_pools(self, query_params=None, return_object_only=True):
142 """Get a list of pool objects.
143
144 :param query_params: The optional query parameters to append to the
145 request. Ex. fields=id&fields=name
146 :param return_object_only: If True, the response returns the object
147 inside the root tag. False returns the full
148 response from the API.
149 :raises AssertionError: if the expected_code isn't a valid http success
150 response code
151 :raises BadRequest: If a 400 response code is received
152 :raises Conflict: If a 409 response code is received
153 :raises Forbidden: If a 403 response code is received
154 :raises Gone: If a 410 response code is received
155 :raises InvalidContentType: If a 415 response code is received
156 :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
157 :raises InvalidHttpSuccessCode: if the read code isn't an expected
158 http success code
159 :raises NotFound: If a 404 response code is received
160 :raises NotImplemented: If a 501 response code is received
161 :raises OverLimit: If a 413 response code is received and over_limit is
162 not in the response body
163 :raises RateLimitExceeded: If a 413 response code is received and
164 over_limit is in the response body
165 :raises ServerFault: If a 500 response code is received
166 :raises Unauthorized: If a 401 response code is received
167 :raises UnexpectedContentType: If the content-type of the response
168 isn't an expect type
169 :raises UnexpectedResponseCode: If a response code above 400 is
170 received and it doesn't fall into any
171 of the handled checks
172 :raises UnprocessableEntity: If a 422 response code is received and
173 couldn't be parsed
174 :returns: A list of pool objects.
175 """
176 return self._list_objects(query_params=query_params,
177 return_object_only=return_object_only)
178
179 @skip_if_not_implemented
180 def update_pool(self, pool_id, lb_algorithm=Unset, name=Unset,
181 description=Unset, tags=Unset, admin_state_up=Unset,
182 session_persistence=Unset, ca_tls_container_ref=Unset,
183 crl_container_ref=Unset, tls_enabled=Unset,
184 tls_container_ref=Unset, alpn_protocols=Unset,
185 return_object_only=True):
186 """Update a pool.
187
188 :param pool_id: The pool ID to update.
189 :param lb_algorithm: The load balancing algorithm for the pool.
190 :param name: Human-readable name of the resource.
191 :param description: A human-readable description for the resource.
192 :param tags: A human-readable tags of the resource.
193 :param admin_state_up: The administrative state of the resource, which
194 is up (true) or down (false).
195 :param session_persistence: A JSON object specifying the session
196 persistence for the pool or null for no
197 session persistence.
198 :param ca_tls_container_ref: The key manager ref for a secret
199 containing the PEM encoded CA certificate
200 to validate pool members against.
201 :param crl_container_ref: The key manager ref for a secret containing
202 the PEM encoded CRL to use when validating
203 pool members.
204 :param tls_enabled: A boolean, True when the pool should connect to
205 members using TLS.
206 :param tls_container_ref: The key manager ref for a secret containing
207 a PKCS12 bundle with the client
208 authentication certificate and key used
209 when connecting to pool members over TLS.
210 :param alpn_protocols: A list of ALPN protocols for TLS enabled pools.
211 :param return_object_only: If True, the response returns the object
212 inside the root tag. False returns the full
213 response from the API.
214 :raises AssertionError: if the expected_code isn't a valid http success
215 response code
216 :raises BadRequest: If a 400 response code is received
217 :raises Conflict: If a 409 response code is received
218 :raises Forbidden: If a 403 response code is received
219 :raises Gone: If a 410 response code is received
220 :raises InvalidContentType: If a 415 response code is received
221 :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
222 :raises InvalidHttpSuccessCode: if the read code isn't an expected
223 http success code
224 :raises NotFound: If a 404 response code is received
225 :raises NotImplemented: If a 501 response code is received
226 :raises OverLimit: If a 413 response code is received and over_limit is
227 not in the response body
228 :raises RateLimitExceeded: If a 413 response code is received and
229 over_limit is in the response body
230 :raises ServerFault: If a 500 response code is received
231 :raises Unauthorized: If a 401 response code is received
232 :raises UnexpectedContentType: If the content-type of the response
233 isn't an expect type
234 :raises UnexpectedResponseCode: If a response code above 400 is
235 received and it doesn't fall into any
236 of the handled checks
237 :raises UnprocessableEntity: If a 422 response code is received and
238 couldn't be parsed
239 :returns: A pool object.
240 """
241 kwargs = {arg: value for arg, value in locals().items()
242 if arg != 'self' and value is not Unset}
243 kwargs['obj_id'] = kwargs.pop('pool_id')
244 return self._update_object(**kwargs)
245
246 @skip_if_not_implemented
247 def delete_pool(self, pool_id, ignore_errors=False):
248 """Delete a pool.
249
250 :param pool_id: The pool ID to delete.
251 :param ignore_errors: True if errors should be ignored.
252 :raises AssertionError: if the expected_code isn't a valid http success
253 response code
254 :raises BadRequest: If a 400 response code is received
255 :raises Conflict: If a 409 response code is received
256 :raises Forbidden: If a 403 response code is received
257 :raises Gone: If a 410 response code is received
258 :raises InvalidContentType: If a 415 response code is received
259 :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
260 :raises InvalidHttpSuccessCode: if the read code isn't an expected
261 http success code
262 :raises NotFound: If a 404 response code is received
263 :raises NotImplemented: If a 501 response code is received
264 :raises OverLimit: If a 413 response code is received and over_limit is
265 not in the response body
266 :raises RateLimitExceeded: If a 413 response code is received and
267 over_limit is in the response body
268 :raises ServerFault: If a 500 response code is received
269 :raises Unauthorized: If a 401 response code is received
270 :raises UnexpectedContentType: If the content-type of the response
271 isn't an expect type
272 :raises UnexpectedResponseCode: If a response code above 400 is
273 received and it doesn't fall into any
274 of the handled checks
275 :raises UnprocessableEntity: If a 422 response code is received and
276 couldn't be parsed
277 :returns: None if ignore_errors is True, the response status code
278 if not.
279 """
280 return self._delete_obj(obj_id=pool_id,
281 ignore_errors=ignore_errors)