Browse Source

Add the flavor profile service client.

This patch adds the flavor profile service client to the Octavia tempest
plugin.

Change-Id: I461b069064e6329ea95ad26d697f11c74cc4dd5c
Michael Johnson 3 months ago
parent
commit
fd90e15bd9

+ 4
- 0
octavia_tempest_plugin/clients.py View File

@@ -17,6 +17,8 @@ from tempest import config
17 17
 
18 18
 from octavia_tempest_plugin.services.load_balancer.v2 import (
19 19
     amphora_client)
20
+from octavia_tempest_plugin.services.load_balancer.v2 import (
21
+    flavor_profile_client)
20 22
 from octavia_tempest_plugin.services.load_balancer.v2 import (
21 23
     healthmonitor_client)
22 24
 from octavia_tempest_plugin.services.load_balancer.v2 import (
@@ -57,3 +59,5 @@ class ManagerV2(clients.Manager):
57 59
             self.auth_provider, SERVICE_TYPE, CONF.identity.region)
58 60
         self.amphora_client = amphora_client.AmphoraClient(
59 61
             self.auth_provider, SERVICE_TYPE, CONF.identity.region)
62
+        self.flavor_profile_client = flavor_profile_client.FlavorProfileClient(
63
+            self.auth_provider, SERVICE_TYPE, CONF.identity.region)

+ 218
- 0
octavia_tempest_plugin/services/load_balancer/v2/flavor_profile_client.py View File

@@ -0,0 +1,218 @@
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 octavia_tempest_plugin.services.load_balancer.v2 import base_client
17
+
18
+Unset = base_client.Unset
19
+
20
+
21
+class FlavorProfileClient(base_client.BaseLBaaSClient):
22
+
23
+    root_tag = 'flavorprofile'
24
+    list_root_tag = 'flavorprofiles'
25
+
26
+    def create_flavor_profile(self, name, provider_name, flavor_data,
27
+                              return_object_only=True):
28
+        """Create a flavor profile.
29
+
30
+        :param name: Human-readable name of the resource.
31
+        :param provider_name: The octavia provider name.
32
+        :param flavor_data: The JSON string containing the flavor metadata.
33
+        :raises AssertionError: if the expected_code isn't a valid http success
34
+                                response code
35
+        :raises BadRequest: If a 400 response code is received
36
+        :raises Conflict: If a 409 response code is received
37
+        :raises Forbidden: If a 403 response code is received
38
+        :raises Gone: If a 410 response code is received
39
+        :raises InvalidContentType: If a 415 response code is received
40
+        :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
41
+        :raises InvalidHttpSuccessCode: if the read code isn't an expected
42
+                                        http success code
43
+        :raises NotFound: If a 404 response code is received
44
+        :raises NotImplemented: If a 501 response code is received
45
+        :raises OverLimit: If a 413 response code is received and over_limit is
46
+                           not in the response body
47
+        :raises RateLimitExceeded: If a 413 response code is received and
48
+                                   over_limit is in the response body
49
+        :raises ServerFault: If a 500 response code is received
50
+        :raises Unauthorized: If a 401 response code is received
51
+        :raises UnexpectedContentType: If the content-type of the response
52
+                                       isn't an expect type
53
+        :raises UnexpectedResponseCode: If a response code above 400 is
54
+                                        received and it doesn't fall into any
55
+                                        of the handled checks
56
+        :raises UnprocessableEntity: If a 422 response code is received and
57
+                                     couldn't be parsed
58
+        :returns: A flavor profile object.
59
+        """
60
+        kwargs = {arg: value for arg, value in locals().items()
61
+                  if arg != 'self' and value is not Unset}
62
+        return self._create_object(**kwargs)
63
+
64
+    def show_flavor_profile(self, flavorprofile_id, query_params=None,
65
+                            return_object_only=True):
66
+        """Get the flavor profile details.
67
+
68
+        :param flavorprofile_id: The flavor profile ID to query.
69
+        :param query_params: The optional query parameters to append to the
70
+                             request. Ex. fields=id&fields=name
71
+        :param return_object_only: If True, the response returns the object
72
+                                   inside the root tag. False returns the full
73
+                                   response from the API.
74
+        :raises AssertionError: if the expected_code isn't a valid http success
75
+                                response code
76
+        :raises BadRequest: If a 400 response code is received
77
+        :raises Conflict: If a 409 response code is received
78
+        :raises Forbidden: If a 403 response code is received
79
+        :raises Gone: If a 410 response code is received
80
+        :raises InvalidContentType: If a 415 response code is received
81
+        :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
82
+        :raises InvalidHttpSuccessCode: if the read code isn't an expected
83
+                                        http success code
84
+        :raises NotFound: If a 404 response code is received
85
+        :raises NotImplemented: If a 501 response code is received
86
+        :raises OverLimit: If a 413 response code is received and over_limit is
87
+                           not in the response body
88
+        :raises RateLimitExceeded: If a 413 response code is received and
89
+                                   over_limit is in the response body
90
+        :raises ServerFault: If a 500 response code is received
91
+        :raises Unauthorized: If a 401 response code is received
92
+        :raises UnexpectedContentType: If the content-type of the response
93
+                                       isn't an expect type
94
+        :raises UnexpectedResponseCode: If a response code above 400 is
95
+                                        received and it doesn't fall into any
96
+                                        of the handled checks
97
+        :raises UnprocessableEntity: If a 422 response code is received and
98
+                                     couldn't be parsed
99
+        :returns: A flavor profile object.
100
+        """
101
+        return self._show_object(obj_id=flavorprofile_id,
102
+                                 query_params=query_params,
103
+                                 return_object_only=return_object_only)
104
+
105
+    def list_flavor_profiles(self, query_params=None, return_object_only=True):
106
+        """Get a list of flavor profile objects.
107
+
108
+        :param query_params: The optional query parameters to append to the
109
+                             request. Ex. fields=id&fields=name
110
+        :param return_object_only: If True, the response returns the object
111
+                                   inside the root tag. False returns the full
112
+                                   response from the API.
113
+        :raises AssertionError: if the expected_code isn't a valid http success
114
+                                response code
115
+        :raises BadRequest: If a 400 response code is received
116
+        :raises Conflict: If a 409 response code is received
117
+        :raises Forbidden: If a 403 response code is received
118
+        :raises Gone: If a 410 response code is received
119
+        :raises InvalidContentType: If a 415 response code is received
120
+        :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
121
+        :raises InvalidHttpSuccessCode: if the read code isn't an expected
122
+                                        http success code
123
+        :raises NotFound: If a 404 response code is received
124
+        :raises NotImplemented: If a 501 response code is received
125
+        :raises OverLimit: If a 413 response code is received and over_limit is
126
+                           not in the response body
127
+        :raises RateLimitExceeded: If a 413 response code is received and
128
+                                   over_limit is in the response body
129
+        :raises ServerFault: If a 500 response code is received
130
+        :raises Unauthorized: If a 401 response code is received
131
+        :raises UnexpectedContentType: If the content-type of the response
132
+                                       isn't an expect type
133
+        :raises UnexpectedResponseCode: If a response code above 400 is
134
+                                        received and it doesn't fall into any
135
+                                        of the handled checks
136
+        :raises UnprocessableEntity: If a 422 response code is received and
137
+                                     couldn't be parsed
138
+        :returns: A list of flavor profile objects.
139
+        """
140
+        return self._list_objects(query_params=query_params,
141
+                                  return_object_only=return_object_only)
142
+
143
+    def update_flavor_profile(
144
+        self, flavorprofile_id, name=Unset, provider_name=Unset,
145
+        flavor_data=Unset, return_object_only=True):
146
+        """Update a flavor profile.
147
+
148
+        :param flavorprofile_id: The flavor profile ID to update.
149
+        :param name: Human-readable name of the resource.
150
+        :param provider_name: The octavia provider name.
151
+        :param flavor_data: The JSON string containing the flavor metadata.
152
+        :raises AssertionError: if the expected_code isn't a valid http success
153
+                                response code
154
+        :raises BadRequest: If a 400 response code is received
155
+        :raises Conflict: If a 409 response code is received
156
+        :raises Forbidden: If a 403 response code is received
157
+        :raises Gone: If a 410 response code is received
158
+        :raises InvalidContentType: If a 415 response code is received
159
+        :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
160
+        :raises InvalidHttpSuccessCode: if the read code isn't an expected
161
+                                        http success code
162
+        :raises NotFound: If a 404 response code is received
163
+        :raises NotImplemented: If a 501 response code is received
164
+        :raises OverLimit: If a 413 response code is received and over_limit is
165
+                           not in the response body
166
+        :raises RateLimitExceeded: If a 413 response code is received and
167
+                                   over_limit is in the response body
168
+        :raises ServerFault: If a 500 response code is received
169
+        :raises Unauthorized: If a 401 response code is received
170
+        :raises UnexpectedContentType: If the content-type of the response
171
+                                       isn't an expect type
172
+        :raises UnexpectedResponseCode: If a response code above 400 is
173
+                                        received and it doesn't fall into any
174
+                                        of the handled checks
175
+        :raises UnprocessableEntity: If a 422 response code is received and
176
+                                     couldn't be parsed
177
+        :returns: A flavor profile object.
178
+        """
179
+        kwargs = {arg: value for arg, value in locals().items()
180
+                  if arg != 'self' and value is not Unset}
181
+        kwargs['obj_id'] = kwargs.pop('flavorprofile_id')
182
+        return self._update_object(**kwargs)
183
+
184
+    def delete_flavor_profile(self, flavorprofile_id, ignore_errors=False):
185
+        """Delete a flavor profile.
186
+
187
+        :param flavorprofile_id: The flavor profile ID to delete.
188
+        :param ignore_errors: True if errors should be ignored.
189
+        :raises AssertionError: if the expected_code isn't a valid http success
190
+                                response code
191
+        :raises BadRequest: If a 400 response code is received
192
+        :raises Conflict: If a 409 response code is received
193
+        :raises Forbidden: If a 403 response code is received
194
+        :raises Gone: If a 410 response code is received
195
+        :raises InvalidContentType: If a 415 response code is received
196
+        :raises InvalidHTTPResponseBody: The response body wasn't valid JSON
197
+        :raises InvalidHttpSuccessCode: if the read code isn't an expected
198
+                                        http success code
199
+        :raises NotFound: If a 404 response code is received
200
+        :raises NotImplemented: If a 501 response code is received
201
+        :raises OverLimit: If a 413 response code is received and over_limit is
202
+                           not in the response body
203
+        :raises RateLimitExceeded: If a 413 response code is received and
204
+                                   over_limit is in the response body
205
+        :raises ServerFault: If a 500 response code is received
206
+        :raises Unauthorized: If a 401 response code is received
207
+        :raises UnexpectedContentType: If the content-type of the response
208
+                                       isn't an expect type
209
+        :raises UnexpectedResponseCode: If a response code above 400 is
210
+                                        received and it doesn't fall into any
211
+                                        of the handled checks
212
+        :raises UnprocessableEntity: If a 422 response code is received and
213
+                                     couldn't be parsed
214
+        :returns: None if ignore_errors is True, the response status code
215
+                  if not.
216
+        """
217
+        return self._delete_obj(obj_id=flavorprofile_id,
218
+                                ignore_errors=ignore_errors)

Loading…
Cancel
Save