blob: bcfc40b9a97a001c1ef3b2788ee8508fe9fd7f05 [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 Fazekas96524032013-01-29 19:52:49 +010089class BadRequest(RestClientException):
Jay Pipes5135bfc2012-01-05 15:46:49 -050090 message = "Bad request"
Adam Gandelmane2d46b42012-01-03 17:40:44 -080091
92
Attila Fazekas96524032013-01-29 19:52:49 +010093class AuthenticationFailure(RestClientException):
Jay Pipes5135bfc2012-01-05 15:46:49 -050094 message = ("Authentication with user %(user)s and password "
95 "%(password)s failed")
Brian Waldon738cd632011-12-12 18:45:09 -050096
97
Jay Pipes5135bfc2012-01-05 15:46:49 -050098class EndpointNotFound(TempestException):
99 message = "Endpoint not found"
Brian Waldon738cd632011-12-12 18:45:09 -0500100
Jay Pipes5135bfc2012-01-05 15:46:49 -0500101
Jay Pipes9b043842012-01-23 23:34:26 -0500102class RateLimitExceeded(TempestException):
103 message = ("Rate limit exceeded.\nMessage: %(message)s\n"
104 "Details: %(details)s")
105
106
Jay Pipes5135bfc2012-01-05 15:46:49 -0500107class OverLimit(TempestException):
108 message = "Quota exceeded"
109
110
111class ComputeFault(TempestException):
112 message = "Got compute fault"
113
114
Matthew Treinish72ea4422013-02-07 14:42:49 -0500115class ImageFault(TempestException):
116 message = "Got image fault"
117
118
Jay Pipesedba0622012-07-08 21:34:36 -0400119class IdentityError(TempestException):
120 message = "Got identity error"
121
122
Attila Fazekas96524032013-01-29 19:52:49 +0100123class Duplicate(RestClientException):
Jay Pipes5135bfc2012-01-05 15:46:49 -0500124 message = "An object with that identifier already exists"
Daryl Walleck6b9b2882012-04-08 21:43:39 -0500125
126
127class SSHTimeout(TempestException):
128 message = ("Connection to the %(host)s via SSH timed out.\n"
Jaroslav Hennerab327842012-09-11 15:44:29 +0200129 "User: %(user)s, Password: %(password)s")
130
131
132class SSHExecCommandFailed(TempestException):
Sean Daguef237ccb2013-01-04 15:19:14 -0500133 """Raised when remotely executed command returns nonzero status."""
Jaroslav Hennerab327842012-09-11 15:44:29 +0200134 message = ("Command '%(command)s', exit status: %(exit_status)d, "
135 "Error:\n%(strerror)s")
Daryl Walleck6b9b2882012-04-08 21:43:39 -0500136
137
138class ServerUnreachable(TempestException):
139 message = "The server is not reachable via the configured network"
Jay Pipes051075a2012-04-28 17:39:37 -0400140
141
142class SQLException(TempestException):
143 message = "SQL error: %(message)s"
Attila Fazekasa23f5002012-10-23 19:32:45 +0200144
145
146class TearDownException(TempestException):
147 message = "%(num)d cleanUp operation failed"
Attila Fazekas72c7a5f2012-12-03 17:17:23 +0100148
149
Attila Fazekas96524032013-01-29 19:52:49 +0100150class RFCViolation(RestClientException):
Attila Fazekas72c7a5f2012-12-03 17:17:23 +0100151 message = "RFC Violation"
152
153
154class ResponseWithNonEmptyBody(RFCViolation):
Armando Migliaccio93225f62012-12-12 13:56:55 +0000155 message = ("RFC Violation! Response with %(status)d HTTP Status Code "
Attila Fazekas72c7a5f2012-12-03 17:17:23 +0100156 "MUST NOT have a body")
157
158
159class ResponseWithEntity(RFCViolation):
160 message = ("RFC Violation! Response with 205 HTTP Status Code "
161 "MUST NOT have an entity")