blob: 0bab9c71cd9ad3c2262d1bac00f3b8b3d86df648 [file] [log] [blame]
Attila Fazekasa23f5002012-10-23 19:32:45 +02001# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
ZhiQiang Fan39f97222013-09-20 04:49:44 +08003# Copyright 2012 OpenStack Foundation
Attila Fazekasa23f5002012-10-23 19:32:45 +02004# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
17
ivan-zhu4322bb72013-02-04 11:51:16 +080018import testtools
Attila Fazekas96524032013-01-29 19:52:49 +010019
Attila Fazekasa23f5002012-10-23 19:32:45 +020020
Jay Pipes5135bfc2012-01-05 15:46:49 -050021class TempestException(Exception):
22 """
23 Base Tempest Exception
24
25 To correctly use this class, inherit from it and define
26 a 'message' property. That message will get printf'd
27 with the keyword arguments provided to the constructor.
28 """
29 message = "An unknown exception occurred"
30
31 def __init__(self, *args, **kwargs):
Attila Fazekas96524032013-01-29 19:52:49 +010032 super(TempestException, self).__init__()
Jay Pipes5135bfc2012-01-05 15:46:49 -050033 try:
34 self._error_string = self.message % kwargs
35 except Exception:
36 # at least get the core message out if something happened
37 self._error_string = self.message
38 if len(args) > 0:
39 # If there is a non-kwarg parameter, assume it's the error
40 # message or reason description and tack it on to the end
41 # of the exception message
42 # Convert all arguments into their string representations...
43 args = ["%s" % arg for arg in args]
44 self._error_string = (self._error_string +
45 "\nDetails: %s" % '\n'.join(args))
Daryl Walleckf0087032011-12-18 13:37:05 -060046
47 def __str__(self):
Jay Pipes5135bfc2012-01-05 15:46:49 -050048 return self._error_string
Daryl Walleck1465d612011-11-02 02:22:15 -050049
50
Daryl Walleck587385b2012-03-03 13:00:26 -060051class InvalidConfiguration(TempestException):
52 message = "Invalid Configuration"
53
54
Attila Fazekas96524032013-01-29 19:52:49 +010055class RestClientException(TempestException,
ivan-zhu4322bb72013-02-04 11:51:16 +080056 testtools.TestCase.failureException):
Attila Fazekas96524032013-01-29 19:52:49 +010057 pass
58
59
Attila Fazekas54a42862013-07-28 22:31:06 +020060class InvalidHttpSuccessCode(RestClientException):
61 message = "The success code is different than the expected one"
62
63
Attila Fazekas96524032013-01-29 19:52:49 +010064class NotFound(RestClientException):
Jay Pipes5135bfc2012-01-05 15:46:49 -050065 message = "Object not found"
Daryl Walleckadea1fa2011-11-15 18:36:39 -060066
67
Attila Fazekas96524032013-01-29 19:52:49 +010068class Unauthorized(RestClientException):
Daryl Walleckced8eb82012-03-19 13:52:37 -050069 message = 'Unauthorized'
70
71
Matthew Treinish16c43792013-09-09 19:55:23 +000072class InvalidServiceTag(RestClientException):
73 message = "Invalid service tag"
74
75
Jay Pipes5135bfc2012-01-05 15:46:49 -050076class TimeoutException(TempestException):
77 message = "Request timed out"
Brian Lamar12d9b292011-12-08 12:41:21 -050078
79
Jay Pipes5135bfc2012-01-05 15:46:49 -050080class BuildErrorException(TempestException):
81 message = "Server %(server_id)s failed to build and is in ERROR status"
Daryl Wallecked8bef32011-12-05 23:02:08 -060082
83
Attila Fazekas195f1d42013-10-24 10:33:16 +020084class ImageKilledException(TempestException):
Attila Fazekas9dfb9072013-11-13 16:45:36 +010085 message = "Image %(image_id)s 'killed' while waiting for '%(status)s'"
Attila Fazekas195f1d42013-10-24 10:33:16 +020086
87
Katherine Elliott74f68512012-05-18 10:19:22 -060088class AddImageException(TempestException):
Armando Migliaccio93225f62012-12-12 13:56:55 +000089 message = "Image %(image_id)s failed to become ACTIVE in the allotted time"
Katherine Elliott74f68512012-05-18 10:19:22 -060090
91
Attila Fazekasa23f5002012-10-23 19:32:45 +020092class EC2RegisterImageException(TempestException):
Armando Migliaccio93225f62012-12-12 13:56:55 +000093 message = ("Image %(image_id)s failed to become 'available' "
Attila Fazekasa23f5002012-10-23 19:32:45 +020094 "in the allotted time")
95
96
rajalakshmi-ganesane3bb58f2012-05-16 12:01:15 +053097class VolumeBuildErrorException(TempestException):
98 message = "Volume %(volume_id)s failed to build and is in ERROR status"
99
100
Attila Fazekas36b1fcf2013-01-31 16:41:04 +0100101class SnapshotBuildErrorException(TempestException):
102 message = "Snapshot %(snapshot_id)s failed to build and is in ERROR status"
103
104
Steve Bakerc60e4e32013-05-06 15:22:41 +1200105class StackBuildErrorException(TempestException):
106 message = ("Stack %(stack_identifier)s is in %(stack_status)s status "
107 "due to '%(stack_status_reason)s'")
108
109
Attila Fazekas96524032013-01-29 19:52:49 +0100110class BadRequest(RestClientException):
Jay Pipes5135bfc2012-01-05 15:46:49 -0500111 message = "Bad request"
Adam Gandelmane2d46b42012-01-03 17:40:44 -0800112
113
Wangpana9b54c62013-02-28 11:04:32 +0800114class UnprocessableEntity(RestClientException):
115 message = "Unprocessable entity"
116
117
Attila Fazekas96524032013-01-29 19:52:49 +0100118class AuthenticationFailure(RestClientException):
Jay Pipes5135bfc2012-01-05 15:46:49 -0500119 message = ("Authentication with user %(user)s and password "
Matthew Treinishb86cda92013-07-29 11:22:23 -0400120 "%(password)s failed auth using tenant %(tenant)s.")
Brian Waldon738cd632011-12-12 18:45:09 -0500121
122
Jay Pipes5135bfc2012-01-05 15:46:49 -0500123class EndpointNotFound(TempestException):
124 message = "Endpoint not found"
Brian Waldon738cd632011-12-12 18:45:09 -0500125
Jay Pipes5135bfc2012-01-05 15:46:49 -0500126
Jay Pipes9b043842012-01-23 23:34:26 -0500127class RateLimitExceeded(TempestException):
128 message = ("Rate limit exceeded.\nMessage: %(message)s\n"
129 "Details: %(details)s")
130
131
Jay Pipes5135bfc2012-01-05 15:46:49 -0500132class OverLimit(TempestException):
133 message = "Quota exceeded"
134
135
Anju5c3e510c2013-10-18 06:40:29 +0530136class ServerFault(TempestException):
137 message = "Got server fault"
Jay Pipes5135bfc2012-01-05 15:46:49 -0500138
139
Matthew Treinish72ea4422013-02-07 14:42:49 -0500140class ImageFault(TempestException):
141 message = "Got image fault"
142
143
Jay Pipesedba0622012-07-08 21:34:36 -0400144class IdentityError(TempestException):
145 message = "Got identity error"
146
147
Anju5c3e510c2013-10-18 06:40:29 +0530148class Conflict(RestClientException):
Jay Pipes5135bfc2012-01-05 15:46:49 -0500149 message = "An object with that identifier already exists"
Daryl Walleck6b9b2882012-04-08 21:43:39 -0500150
151
152class SSHTimeout(TempestException):
153 message = ("Connection to the %(host)s via SSH timed out.\n"
Jaroslav Hennerab327842012-09-11 15:44:29 +0200154 "User: %(user)s, Password: %(password)s")
155
156
157class SSHExecCommandFailed(TempestException):
Sean Daguef237ccb2013-01-04 15:19:14 -0500158 """Raised when remotely executed command returns nonzero status."""
Jaroslav Hennerab327842012-09-11 15:44:29 +0200159 message = ("Command '%(command)s', exit status: %(exit_status)d, "
160 "Error:\n%(strerror)s")
Daryl Walleck6b9b2882012-04-08 21:43:39 -0500161
162
163class ServerUnreachable(TempestException):
164 message = "The server is not reachable via the configured network"
Jay Pipes051075a2012-04-28 17:39:37 -0400165
166
167class SQLException(TempestException):
168 message = "SQL error: %(message)s"
Attila Fazekasa23f5002012-10-23 19:32:45 +0200169
170
171class TearDownException(TempestException):
172 message = "%(num)d cleanUp operation failed"
Attila Fazekas72c7a5f2012-12-03 17:17:23 +0100173
174
Attila Fazekas96524032013-01-29 19:52:49 +0100175class RFCViolation(RestClientException):
Attila Fazekas72c7a5f2012-12-03 17:17:23 +0100176 message = "RFC Violation"
177
178
179class ResponseWithNonEmptyBody(RFCViolation):
Armando Migliaccio93225f62012-12-12 13:56:55 +0000180 message = ("RFC Violation! Response with %(status)d HTTP Status Code "
Attila Fazekas72c7a5f2012-12-03 17:17:23 +0100181 "MUST NOT have a body")
182
183
184class ResponseWithEntity(RFCViolation):
185 message = ("RFC Violation! Response with 205 HTTP Status Code "
186 "MUST NOT have an entity")
Rohan Kanade433994a2013-12-05 22:34:07 +0530187
188
189class InvalidHTTPResponseBody(RestClientException):
190 message = "HTTP response body is invalid json or xml"