Debian Codegraph @

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