Browse Source

Add the flavor service client.

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

Change-Id: Iecadff4065c3394918ac7342d139f261f3d28e0c
Michael Johnson 3 months ago
parent
commit
cfb0254a10

+ 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_client)
20 22
 from octavia_tempest_plugin.services.load_balancer.v2 import (
21 23
     flavor_profile_client)
22 24
 from octavia_tempest_plugin.services.load_balancer.v2 import (
@@ -61,3 +63,5 @@ class ManagerV2(clients.Manager):
61 63
             self.auth_provider, SERVICE_TYPE, CONF.identity.region)
62 64
         self.flavor_profile_client = flavor_profile_client.FlavorProfileClient(
63 65
             self.auth_provider, SERVICE_TYPE, CONF.identity.region)
66
+        self.flavor_client = flavor_client.FlavorClient(
67
+            self.auth_provider, SERVICE_TYPE, CONF.identity.region)

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

Loading…
Cancel
Save