Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame^] | 1 | # 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 | |
| 18 | |
Jay Pipes | 5135bfc | 2012-01-05 15:46:49 -0500 | [diff] [blame] | 19 | class 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 | try: |
| 31 | self._error_string = self.message % kwargs |
| 32 | except Exception: |
| 33 | # at least get the core message out if something happened |
| 34 | self._error_string = self.message |
| 35 | if len(args) > 0: |
| 36 | # If there is a non-kwarg parameter, assume it's the error |
| 37 | # message or reason description and tack it on to the end |
| 38 | # of the exception message |
| 39 | # Convert all arguments into their string representations... |
| 40 | args = ["%s" % arg for arg in args] |
| 41 | self._error_string = (self._error_string + |
| 42 | "\nDetails: %s" % '\n'.join(args)) |
Daryl Walleck | f008703 | 2011-12-18 13:37:05 -0600 | [diff] [blame] | 43 | |
| 44 | def __str__(self): |
Jay Pipes | 5135bfc | 2012-01-05 15:46:49 -0500 | [diff] [blame] | 45 | return self._error_string |
Daryl Walleck | 1465d61 | 2011-11-02 02:22:15 -0500 | [diff] [blame] | 46 | |
| 47 | |
Daryl Walleck | 587385b | 2012-03-03 13:00:26 -0600 | [diff] [blame] | 48 | class InvalidConfiguration(TempestException): |
| 49 | message = "Invalid Configuration" |
| 50 | |
| 51 | |
Jay Pipes | 5135bfc | 2012-01-05 15:46:49 -0500 | [diff] [blame] | 52 | class NotFound(TempestException): |
| 53 | message = "Object not found" |
Daryl Walleck | adea1fa | 2011-11-15 18:36:39 -0600 | [diff] [blame] | 54 | |
| 55 | |
Daryl Walleck | ced8eb8 | 2012-03-19 13:52:37 -0500 | [diff] [blame] | 56 | class Unauthorized(TempestException): |
| 57 | message = 'Unauthorized' |
| 58 | |
| 59 | |
Jay Pipes | 5135bfc | 2012-01-05 15:46:49 -0500 | [diff] [blame] | 60 | class TimeoutException(TempestException): |
| 61 | message = "Request timed out" |
Brian Lamar | 12d9b29 | 2011-12-08 12:41:21 -0500 | [diff] [blame] | 62 | |
| 63 | |
Jay Pipes | 5135bfc | 2012-01-05 15:46:49 -0500 | [diff] [blame] | 64 | class BuildErrorException(TempestException): |
| 65 | message = "Server %(server_id)s failed to build and is in ERROR status" |
Daryl Walleck | ed8bef3 | 2011-12-05 23:02:08 -0600 | [diff] [blame] | 66 | |
| 67 | |
Katherine Elliott | 74f6851 | 2012-05-18 10:19:22 -0600 | [diff] [blame] | 68 | class AddImageException(TempestException): |
| 69 | message = "Image %(image_id) failed to become ACTIVE in the allotted time" |
| 70 | |
| 71 | |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame^] | 72 | class EC2RegisterImageException(TempestException): |
| 73 | message = ("Image %(image_id) failed to become 'available' " |
| 74 | "in the allotted time") |
| 75 | |
| 76 | |
rajalakshmi-ganesan | e3bb58f | 2012-05-16 12:01:15 +0530 | [diff] [blame] | 77 | class VolumeBuildErrorException(TempestException): |
| 78 | message = "Volume %(volume_id)s failed to build and is in ERROR status" |
| 79 | |
| 80 | |
Jay Pipes | 5135bfc | 2012-01-05 15:46:49 -0500 | [diff] [blame] | 81 | class BadRequest(TempestException): |
| 82 | message = "Bad request" |
Adam Gandelman | e2d46b4 | 2012-01-03 17:40:44 -0800 | [diff] [blame] | 83 | |
| 84 | |
Jay Pipes | 5135bfc | 2012-01-05 15:46:49 -0500 | [diff] [blame] | 85 | class AuthenticationFailure(TempestException): |
| 86 | message = ("Authentication with user %(user)s and password " |
| 87 | "%(password)s failed") |
Brian Waldon | 738cd63 | 2011-12-12 18:45:09 -0500 | [diff] [blame] | 88 | |
| 89 | |
Jay Pipes | 5135bfc | 2012-01-05 15:46:49 -0500 | [diff] [blame] | 90 | class EndpointNotFound(TempestException): |
| 91 | message = "Endpoint not found" |
Brian Waldon | 738cd63 | 2011-12-12 18:45:09 -0500 | [diff] [blame] | 92 | |
Jay Pipes | 5135bfc | 2012-01-05 15:46:49 -0500 | [diff] [blame] | 93 | |
Jay Pipes | 9b04384 | 2012-01-23 23:34:26 -0500 | [diff] [blame] | 94 | class RateLimitExceeded(TempestException): |
| 95 | message = ("Rate limit exceeded.\nMessage: %(message)s\n" |
| 96 | "Details: %(details)s") |
| 97 | |
| 98 | |
Jay Pipes | 5135bfc | 2012-01-05 15:46:49 -0500 | [diff] [blame] | 99 | class OverLimit(TempestException): |
| 100 | message = "Quota exceeded" |
| 101 | |
| 102 | |
| 103 | class ComputeFault(TempestException): |
| 104 | message = "Got compute fault" |
| 105 | |
| 106 | |
Jay Pipes | edba062 | 2012-07-08 21:34:36 -0400 | [diff] [blame] | 107 | class IdentityError(TempestException): |
| 108 | message = "Got identity error" |
| 109 | |
| 110 | |
Jay Pipes | 5135bfc | 2012-01-05 15:46:49 -0500 | [diff] [blame] | 111 | class Duplicate(TempestException): |
| 112 | message = "An object with that identifier already exists" |
Daryl Walleck | 6b9b288 | 2012-04-08 21:43:39 -0500 | [diff] [blame] | 113 | |
| 114 | |
| 115 | class SSHTimeout(TempestException): |
| 116 | message = ("Connection to the %(host)s via SSH timed out.\n" |
Jaroslav Henner | ab32784 | 2012-09-11 15:44:29 +0200 | [diff] [blame] | 117 | "User: %(user)s, Password: %(password)s") |
| 118 | |
| 119 | |
| 120 | class SSHExecCommandFailed(TempestException): |
| 121 | ''' Raised when remotely executed command returns nonzero status. ''' |
| 122 | message = ("Command '%(command)s', exit status: %(exit_status)d, " |
| 123 | "Error:\n%(strerror)s") |
Daryl Walleck | 6b9b288 | 2012-04-08 21:43:39 -0500 | [diff] [blame] | 124 | |
| 125 | |
| 126 | class ServerUnreachable(TempestException): |
| 127 | message = "The server is not reachable via the configured network" |
Jay Pipes | 051075a | 2012-04-28 17:39:37 -0400 | [diff] [blame] | 128 | |
| 129 | |
| 130 | class SQLException(TempestException): |
| 131 | message = "SQL error: %(message)s" |
Attila Fazekas | a23f500 | 2012-10-23 19:32:45 +0200 | [diff] [blame^] | 132 | |
| 133 | |
| 134 | class TearDownException(TempestException): |
| 135 | message = "%(num)d cleanUp operation failed" |