blob: 235a2e77e8977119bbc7d8de6c1236e581e58d53 [file] [log] [blame]
Attila Fazekasa23f5002012-10-23 19:32:45 +02001# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
3# Copyright 2012 OpenStack, LLC
4# 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
60class NotFound(RestClientException):
Jay Pipes5135bfc2012-01-05 15:46:49 -050061 message = "Object not found"
Daryl Walleckadea1fa2011-11-15 18:36:39 -060062
63
Attila Fazekas96524032013-01-29 19:52:49 +010064class Unauthorized(RestClientException):
Daryl Walleckced8eb82012-03-19 13:52:37 -050065 message = 'Unauthorized'
66
67
Jay Pipes5135bfc2012-01-05 15:46:49 -050068class TimeoutException(TempestException):
69 message = "Request timed out"
Brian Lamar12d9b292011-12-08 12:41:21 -050070
71
Jay Pipes5135bfc2012-01-05 15:46:49 -050072class BuildErrorException(TempestException):
73 message = "Server %(server_id)s failed to build and is in ERROR status"
Daryl Wallecked8bef32011-12-05 23:02:08 -060074
75
Katherine Elliott74f68512012-05-18 10:19:22 -060076class AddImageException(TempestException):
Armando Migliaccio93225f62012-12-12 13:56:55 +000077 message = "Image %(image_id)s failed to become ACTIVE in the allotted time"
Katherine Elliott74f68512012-05-18 10:19:22 -060078
79
Attila Fazekasa23f5002012-10-23 19:32:45 +020080class EC2RegisterImageException(TempestException):
Armando Migliaccio93225f62012-12-12 13:56:55 +000081 message = ("Image %(image_id)s failed to become 'available' "
Attila Fazekasa23f5002012-10-23 19:32:45 +020082 "in the allotted time")
83
84
rajalakshmi-ganesane3bb58f2012-05-16 12:01:15 +053085class VolumeBuildErrorException(TempestException):
86 message = "Volume %(volume_id)s failed to build and is in ERROR status"
87
88
Attila Fazekas36b1fcf2013-01-31 16:41:04 +010089class SnapshotBuildErrorException(TempestException):
90 message = "Snapshot %(snapshot_id)s failed to build and is in ERROR status"
91
92
Attila Fazekas96524032013-01-29 19:52:49 +010093class BadRequest(RestClientException):
Jay Pipes5135bfc2012-01-05 15:46:49 -050094 message = "Bad request"
Adam Gandelmane2d46b42012-01-03 17:40:44 -080095
96
Wangpana9b54c62013-02-28 11:04:32 +080097class UnprocessableEntity(RestClientException):
98 message = "Unprocessable entity"
99
100
Attila Fazekas96524032013-01-29 19:52:49 +0100101class AuthenticationFailure(RestClientException):
Jay Pipes5135bfc2012-01-05 15:46:49 -0500102 message = ("Authentication with user %(user)s and password "
103 "%(password)s failed")
Brian Waldon738cd632011-12-12 18:45:09 -0500104
105
Jay Pipes5135bfc2012-01-05 15:46:49 -0500106class EndpointNotFound(TempestException):
107 message = "Endpoint not found"
Brian Waldon738cd632011-12-12 18:45:09 -0500108
Jay Pipes5135bfc2012-01-05 15:46:49 -0500109
Jay Pipes9b043842012-01-23 23:34:26 -0500110class RateLimitExceeded(TempestException):
111 message = ("Rate limit exceeded.\nMessage: %(message)s\n"
112 "Details: %(details)s")
113
114
Jay Pipes5135bfc2012-01-05 15:46:49 -0500115class OverLimit(TempestException):
116 message = "Quota exceeded"
117
118
119class ComputeFault(TempestException):
120 message = "Got compute fault"
121
122
Matthew Treinish72ea4422013-02-07 14:42:49 -0500123class ImageFault(TempestException):
124 message = "Got image fault"
125
126
Jay Pipesedba0622012-07-08 21:34:36 -0400127class IdentityError(TempestException):
128 message = "Got identity error"
129
130
Attila Fazekas96524032013-01-29 19:52:49 +0100131class Duplicate(RestClientException):
Jay Pipes5135bfc2012-01-05 15:46:49 -0500132 message = "An object with that identifier already exists"
Daryl Walleck6b9b2882012-04-08 21:43:39 -0500133
134
135class SSHTimeout(TempestException):
136 message = ("Connection to the %(host)s via SSH timed out.\n"
Jaroslav Hennerab327842012-09-11 15:44:29 +0200137 "User: %(user)s, Password: %(password)s")
138
139
140class SSHExecCommandFailed(TempestException):
Sean Daguef237ccb2013-01-04 15:19:14 -0500141 """Raised when remotely executed command returns nonzero status."""
Jaroslav Hennerab327842012-09-11 15:44:29 +0200142 message = ("Command '%(command)s', exit status: %(exit_status)d, "
143 "Error:\n%(strerror)s")
Daryl Walleck6b9b2882012-04-08 21:43:39 -0500144
145
146class ServerUnreachable(TempestException):
147 message = "The server is not reachable via the configured network"
Jay Pipes051075a2012-04-28 17:39:37 -0400148
149
150class SQLException(TempestException):
151 message = "SQL error: %(message)s"
Attila Fazekasa23f5002012-10-23 19:32:45 +0200152
153
154class TearDownException(TempestException):
155 message = "%(num)d cleanUp operation failed"
Attila Fazekas72c7a5f2012-12-03 17:17:23 +0100156
157
Attila Fazekas96524032013-01-29 19:52:49 +0100158class RFCViolation(RestClientException):
Attila Fazekas72c7a5f2012-12-03 17:17:23 +0100159 message = "RFC Violation"
160
161
162class ResponseWithNonEmptyBody(RFCViolation):
Armando Migliaccio93225f62012-12-12 13:56:55 +0000163 message = ("RFC Violation! Response with %(status)d HTTP Status Code "
Attila Fazekas72c7a5f2012-12-03 17:17:23 +0100164 "MUST NOT have a body")
165
166
167class ResponseWithEntity(RFCViolation):
168 message = ("RFC Violation! Response with 205 HTTP Status Code "
169 "MUST NOT have an entity")