blob: 4eb1cea7f0c3260f611528cfbf69fa767081d0f7 [file] [log] [blame]
Matthew Treinish8bdf6e32014-04-03 11:49:14 -04001# Copyright 2012 OpenStack Foundation
2# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
16import testtools
17
18
19class TempestException(Exception):
20 """
21 Base Tempest Exception
22
23 To correctly use this class, inherit from it and define
24 a 'message' property. That message will get printf'd
25 with the keyword arguments provided to the constructor.
26 """
27 message = "An unknown exception occurred"
28
29 def __init__(self, *args, **kwargs):
30 super(TempestException, self).__init__()
31 try:
32 self._error_string = self.message % kwargs
33 except Exception:
34 # at least get the core message out if something happened
35 self._error_string = self.message
36 if len(args) > 0:
37 # If there is a non-kwarg parameter, assume it's the error
38 # message or reason description and tack it on to the end
39 # of the exception message
40 # Convert all arguments into their string representations...
41 args = ["%s" % arg for arg in args]
42 self._error_string = (self._error_string +
43 "\nDetails: %s" % '\n'.join(args))
44
45 def __str__(self):
46 return self._error_string
47
48
49class RestClientException(TempestException,
50 testtools.TestCase.failureException):
51 pass
52
53
54class RFCViolation(RestClientException):
55 message = "RFC Violation"
56
57
58class InvalidConfiguration(TempestException):
59 message = "Invalid Configuration"
60
61
62class InvalidCredentials(TempestException):
63 message = "Invalid Credentials"
64
65
66class InvalidHttpSuccessCode(RestClientException):
67 message = "The success code is different than the expected one"
68
69
70class NotFound(RestClientException):
71 message = "Object not found"
72
73
74class Unauthorized(RestClientException):
75 message = 'Unauthorized'
76
77
78class InvalidServiceTag(RestClientException):
79 message = "Invalid service tag"
80
81
82class TimeoutException(TempestException):
83 message = "Request timed out"
84
85
86class BuildErrorException(TempestException):
87 message = "Server %(server_id)s failed to build and is in ERROR status"
88
89
90class ImageKilledException(TempestException):
91 message = "Image %(image_id)s 'killed' while waiting for '%(status)s'"
92
93
94class AddImageException(TempestException):
95 message = "Image %(image_id)s failed to become ACTIVE in the allotted time"
96
97
98class EC2RegisterImageException(TempestException):
99 message = ("Image %(image_id)s failed to become 'available' "
100 "in the allotted time")
101
102
103class VolumeBuildErrorException(TempestException):
104 message = "Volume %(volume_id)s failed to build and is in ERROR status"
105
106
107class SnapshotBuildErrorException(TempestException):
108 message = "Snapshot %(snapshot_id)s failed to build and is in ERROR status"
109
110
111class VolumeBackupException(TempestException):
112 message = "Volume backup %(backup_id)s failed and is in ERROR status"
113
114
115class StackBuildErrorException(TempestException):
116 message = ("Stack %(stack_identifier)s is in %(stack_status)s status "
117 "due to '%(stack_status_reason)s'")
118
119
120class StackResourceBuildErrorException(TempestException):
Masayuki Igawa89ba5682014-04-28 19:25:53 +0900121 message = ("Resource %(resource_name)s in stack %(stack_identifier)s is "
Matthew Treinish8bdf6e32014-04-03 11:49:14 -0400122 "in %(resource_status)s status due to "
123 "'%(resource_status_reason)s'")
124
125
126class BadRequest(RestClientException):
127 message = "Bad request"
128
129
130class UnprocessableEntity(RestClientException):
131 message = "Unprocessable entity"
132
133
134class AuthenticationFailure(RestClientException):
135 message = ("Authentication with user %(user)s and password "
136 "%(password)s failed auth using tenant %(tenant)s.")
137
138
139class EndpointNotFound(TempestException):
140 message = "Endpoint not found"
141
142
143class RateLimitExceeded(TempestException):
144 message = "Rate limit exceeded"
145
146
147class OverLimit(TempestException):
148 message = "Quota exceeded"
149
150
151class ServerFault(TempestException):
152 message = "Got server fault"
153
154
155class ImageFault(TempestException):
156 message = "Got image fault"
157
158
159class IdentityError(TempestException):
160 message = "Got identity error"
161
162
163class Conflict(RestClientException):
164 message = "An object with that identifier already exists"
165
166
167class SSHTimeout(TempestException):
168 message = ("Connection to the %(host)s via SSH timed out.\n"
169 "User: %(user)s, Password: %(password)s")
170
171
172class SSHExecCommandFailed(TempestException):
173 """Raised when remotely executed command returns nonzero status."""
174 message = ("Command '%(command)s', exit status: %(exit_status)d, "
175 "Error:\n%(strerror)s")
176
177
178class ServerUnreachable(TempestException):
179 message = "The server is not reachable via the configured network"
180
181
182class TearDownException(TempestException):
183 message = "%(num)d cleanUp operation failed"
184
185
186class ResponseWithNonEmptyBody(RFCViolation):
187 message = ("RFC Violation! Response with %(status)d HTTP Status Code "
188 "MUST NOT have a body")
189
190
191class ResponseWithEntity(RFCViolation):
192 message = ("RFC Violation! Response with 205 HTTP Status Code "
193 "MUST NOT have an entity")
194
195
196class InvalidHTTPResponseBody(RestClientException):
197 message = "HTTP response body is invalid json or xml"
198
199
Ken'ichi Ohmichi57b384b2014-03-28 13:58:20 +0900200class InvalidHTTPResponseHeader(RestClientException):
201 message = "HTTP response header is invalid"
202
203
Matthew Treinish8bdf6e32014-04-03 11:49:14 -0400204class InvalidContentType(RestClientException):
205 message = "Invalid content type provided"
206
207
208class UnexpectedResponseCode(RestClientException):
209 message = "Unexpected response code received"
210
211
212class InvalidStructure(TempestException):
213 message = "Invalid structure of table with details"