Debian Codegraph @

octavia_tempest_plugin/services/load_balancer/v2/availability_zone_profile_client.py

raw symbols SCIP
1 # Copyright 2019 Rackspace US Inc. All rights reserved.
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
16 from oslo_log import log as logging
17 from tempest.lib import exceptions
18
19 from octavia_tempest_plugin.common.decorators import skip_if_not_implemented
20 from octavia_tempest_plugin.services.load_balancer.v2 import base_client
21
22 LOG = logging.getLogger(__name__)
23 Unset = base_client.Unset
24
25
26 class AvailabilityZoneProfileClient(base_client.BaseLBaaSClient):
27
28 root_tag = 'availability_zone_profile'
29 list_root_tag = 'availability_zone_profiles'
30
31 resource_path = 'availabilityzoneprofiles'
32
33 def __init__(self, *args, **kwargs):
34 super(AvailabilityZoneProfileClient, self).__init__(*args, **kwargs)
35 self.uri = self.base_uri.format(object=self.resource_path)
36
37 @skip_if_not_implemented
38 def create_availability_zone_profile(self, name, provider_name,
39 availability_zone_data,
40 return_object_only=True):
41 """Create an availability zone profile.
42
43 :param name: Human-readable name of the resource.
44 :param provider_name: The octavia provider name.
45 :param availability_zone_data: The JSON string containing the
46 availability zone metadata.
47 :raises AssertionError: if the expected_code isn't a valid http success
48 response code
49 :raises BadRequest: If a 400 response code is received
50 :raises Conflict: If a 409 response code is received
51 :raises Forbidden: If a 403 response code is received
52 :raises Gone: If a 410 response code is received
53 :raises InvalidContentType: If a 415 response code is received
54 :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
55 :raises InvalidHttpSuccessCode: if the read code isn't an expected
56 http success code
57 :raises NotFound: If a 404 response code is received
58 :raises NotImplemented: If a 501 response code is received
59 :raises OverLimit: If a 413 response code is received and over_limit is
60 not in the response body
61 :raises RateLimitExceeded: If a 413 response code is received and
62 over_limit is in the response body
63 :raises ServerFault: If a 500 response code is received
64 :raises Unauthorized: If a 401 response code is received
65 :raises UnexpectedContentType: If the content-type of the response
66 isn't an expect type
67 :raises UnexpectedResponseCode: If a response code above 400 is
68 received and it doesn't fall into any
69 of the handled checks
70 :raises UnprocessableEntity: If a 422 response code is received and
71 couldn't be parsed
72 :returns: An availability zone profile object.
73 """
74 kwargs = {arg: value for arg, value in locals().items()
75 if arg != 'self' and value is not Unset}
76 return self._create_object(**kwargs)
77
78 @skip_if_not_implemented
79 def show_availability_zone_profile(self, availability_zone_profile_id,
80 query_params=None,
81 return_object_only=True):
82 """Get the availability zone profile details.
83
84 :param availability_zone_profile_id: The availability zone profile ID
85 to query.
86 :param query_params: The optional query parameters to append to the
87 request. Ex. fields=id&fields=name
88 :param return_object_only: If True, the response returns the object
89 inside the root tag. False returns the full
90 response from the API.
91 :raises AssertionError: if the expected_code isn't a valid http success
92 response code
93 :raises BadRequest: If a 400 response code is received
94 :raises Conflict: If a 409 response code is received
95 :raises Forbidden: If a 403 response code is received
96 :raises Gone: If a 410 response code is received
97 :raises InvalidContentType: If a 415 response code is received
98 :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
99 :raises InvalidHttpSuccessCode: if the read code isn't an expected
100 http success code
101 :raises NotFound: If a 404 response code is received
102 :raises NotImplemented: If a 501 response code is received
103 :raises OverLimit: If a 413 response code is received and over_limit is
104 not in the response body
105 :raises RateLimitExceeded: If a 413 response code is received and
106 over_limit is in the response body
107 :raises ServerFault: If a 500 response code is received
108 :raises Unauthorized: If a 401 response code is received
109 :raises UnexpectedContentType: If the content-type of the response
110 isn't an expect type
111 :raises UnexpectedResponseCode: If a response code above 400 is
112 received and it doesn't fall into any
113 of the handled checks
114 :raises UnprocessableEntity: If a 422 response code is received and
115 couldn't be parsed
116 :returns: An availability zone profile object.
117 """
118 return self._show_object(obj_id=availability_zone_profile_id,
119 query_params=query_params,
120 return_object_only=return_object_only)
121
122 @skip_if_not_implemented
123 def list_availability_zone_profiles(self, query_params=None,
124 return_object_only=True):
125 """Get a list of availability zone profile objects.
126
127 :param query_params: The optional query parameters to append to the
128 request. Ex. fields=id&fields=name
129 :param return_object_only: If True, the response returns the object
130 inside the root tag. False returns the full
131 response from the API.
132 :raises AssertionError: if the expected_code isn't a valid http success
133 response code
134 :raises BadRequest: If a 400 response code is received
135 :raises Conflict: If a 409 response code is received
136 :raises Forbidden: If a 403 response code is received
137 :raises Gone: If a 410 response code is received
138 :raises InvalidContentType: If a 415 response code is received
139 :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
140 :raises InvalidHttpSuccessCode: if the read code isn't an expected
141 http success code
142 :raises NotFound: If a 404 response code is received
143 :raises NotImplemented: If a 501 response code is received
144 :raises OverLimit: If a 413 response code is received and over_limit is
145 not in the response body
146 :raises RateLimitExceeded: If a 413 response code is received and
147 over_limit is in the response body
148 :raises ServerFault: If a 500 response code is received
149 :raises Unauthorized: If a 401 response code is received
150 :raises UnexpectedContentType: If the content-type of the response
151 isn't an expect type
152 :raises UnexpectedResponseCode: If a response code above 400 is
153 received and it doesn't fall into any
154 of the handled checks
155 :raises UnprocessableEntity: If a 422 response code is received and
156 couldn't be parsed
157 :returns: A list of availability zone profile objects.
158 """
159 return self._list_objects(query_params=query_params,
160 return_object_only=return_object_only)
161
162 @skip_if_not_implemented
163 def update_availability_zone_profile(
164 self, availability_zone_profile_id, name=Unset,
165 provider_name=Unset, availability_zone_data=Unset,
166 return_object_only=True):
167 """Update an availability zone profile.
168
169 :param availability_zone_profile_id: The availability zone profile ID
170 to update.
171 :param name: Human-readable name of the resource.
172 :param provider_name: The octavia provider name.
173 :param availability_zone_data: The JSON string containing the
174 availability zone metadata.
175 :raises AssertionError: if the expected_code isn't a valid http success
176 response code
177 :raises BadRequest: If a 400 response code is received
178 :raises Conflict: If a 409 response code is received
179 :raises Forbidden: If a 403 response code is received
180 :raises Gone: If a 410 response code is received
181 :raises InvalidContentType: If a 415 response code is received
182 :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
183 :raises InvalidHttpSuccessCode: if the read code isn't an expected
184 http success code
185 :raises NotFound: If a 404 response code is received
186 :raises NotImplemented: If a 501 response code is received
187 :raises OverLimit: If a 413 response code is received and over_limit is
188 not in the response body
189 :raises RateLimitExceeded: If a 413 response code is received and
190 over_limit is in the response body
191 :raises ServerFault: If a 500 response code is received
192 :raises Unauthorized: If a 401 response code is received
193 :raises UnexpectedContentType: If the content-type of the response
194 isn't an expect type
195 :raises UnexpectedResponseCode: If a response code above 400 is
196 received and it doesn't fall into any
197 of the handled checks
198 :raises UnprocessableEntity: If a 422 response code is received and
199 couldn't be parsed
200 :returns: An availability zone profile object.
201 """
202 kwargs = {arg: value for arg, value in locals().items()
203 if arg != 'self' and value is not Unset}
204 kwargs['obj_id'] = kwargs.pop('availability_zone_profile_id')
205 return self._update_object(**kwargs)
206
207 @skip_if_not_implemented
208 def delete_availability_zone_profile(self, availability_zone_profile_id,
209 ignore_errors=False):
210 """Delete an availability zone profile.
211
212 :param availability_zone_profile_id: The availability zone profile ID
213 to delete.
214 :param ignore_errors: True if errors should be ignored.
215 :raises AssertionError: if the expected_code isn't a valid http success
216 response code
217 :raises BadRequest: If a 400 response code is received
218 :raises Conflict: If a 409 response code is received
219 :raises Forbidden: If a 403 response code is received
220 :raises Gone: If a 410 response code is received
221 :raises InvalidContentType: If a 415 response code is received
222 :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
223 :raises InvalidHttpSuccessCode: if the read code isn't an expected
224 http success code
225 :raises NotFound: If a 404 response code is received
226 :raises NotImplemented: If a 501 response code is received
227 :raises OverLimit: If a 413 response code is received and over_limit is
228 not in the response body
229 :raises RateLimitExceeded: If a 413 response code is received and
230 over_limit is in the response body
231 :raises ServerFault: If a 500 response code is received
232 :raises Unauthorized: If a 401 response code is received
233 :raises UnexpectedContentType: If the content-type of the response
234 isn't an expect type
235 :raises UnexpectedResponseCode: If a response code above 400 is
236 received and it doesn't fall into any
237 of the handled checks
238 :raises UnprocessableEntity: If a 422 response code is received and
239 couldn't be parsed
240 :returns: None if ignore_errors is True, the response status code
241 if not.
242 """
243 return self._delete_obj(obj_id=availability_zone_profile_id,
244 ignore_errors=ignore_errors)
245
246 def cleanup_availability_zone_profile(self, availability_zone_profile_id):
247 """Delete an availability zone profile for tempest cleanup.
248
249 We cannot use the cleanup_availability_zone_profile method as
250 availability zone profiles do not have a provisioning_status.
251
252 :param availability_zone_profile_id: The availability zone profile ID
253 to delete.
254 :raises AssertionError: if the expected_code isn't a valid http success
255 response code
256 :raises BadRequest: If a 400 response code is received
257 :raises Conflict: If a 409 response code is received
258 :raises Forbidden: If a 403 response code is received
259 :raises Gone: If a 410 response code is received
260 :raises InvalidContentType: If a 415 response code is received
261 :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
262 :raises InvalidHttpSuccessCode: if the read code isn't an expected
263 http success code
264 :raises NotImplemented: If a 501 response code is received
265 :raises OverLimit: If a 413 response code is received and over_limit is
266 not in the response body
267 :raises RateLimitExceeded: If a 413 response code is received and
268 over_limit is in the response body
269 :raises ServerFault: If a 500 response code is received
270 :raises Unauthorized: If a 401 response code is received
271 :raises UnexpectedContentType: If the content-type of the response
272 isn't an expect type
273 :raises UnexpectedResponseCode: If a response code above 400 is
274 received and it doesn't fall into any
275 of the handled checks
276 :raises UnprocessableEntity: If a 422 response code is received and
277 couldn't be parsed
278 :returns: None if ignore_errors is True, the response status code
279 if not.
280 """
281 try:
282 self._delete_obj(obj_id=availability_zone_profile_id)
283 except exceptions.NotFound:
284 # Already gone, cleanup complete
285 LOG.info("Availability zone profile %s is already gone. "
286 "Cleanup considered complete.",
287 availability_zone_profile_id)