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