blob: 5132850d74ca875eb0209d182f88ec037971c709 [file] [log] [blame]
Steve Baker450aa7f2014-08-25 10:37:27 +12001# Licensed under the Apache License, Version 2.0 (the "License"); you may
2# not use this file except in compliance with the License. You may obtain
3# a copy of the License at
4#
5# http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10# License for the specific language governing permissions and limitations
11# under the License.
12
13
14class IntegrationException(Exception):
15 """
16 Base Tempest Exception
17
18 To correctly use this class, inherit from it and define
19 a 'message' property. That message will get printf'd
20 with the keyword arguments provided to the constructor.
21 """
22 message = "An unknown exception occurred"
23
24 def __init__(self, *args, **kwargs):
25 super(IntegrationException, self).__init__()
26 try:
27 self._error_string = self.message % kwargs
28 except Exception:
29 # at least get the core message out if something happened
30 self._error_string = self.message
31 if len(args) > 0:
32 # If there is a non-kwarg parameter, assume it's the error
33 # message or reason description and tack it on to the end
34 # of the exception message
35 # Convert all arguments into their string representations...
36 args = ["%s" % arg for arg in args]
37 self._error_string = (self._error_string +
38 "\nDetails: %s" % '\n'.join(args))
39
40 def __str__(self):
41 return self._error_string
42
43
44class InvalidCredentials(IntegrationException):
45 message = "Invalid Credentials"
46
47
48class TimeoutException(IntegrationException):
49 message = "Request timed out"
50
51
52class BuildErrorException(IntegrationException):
53 message = "Server %(server_id)s failed to build and is in ERROR status"
54
55
56class StackBuildErrorException(IntegrationException):
57 message = ("Stack %(stack_identifier)s is in %(stack_status)s status "
58 "due to '%(stack_status_reason)s'")
59
60
61class StackResourceBuildErrorException(IntegrationException):
62 message = ("Resource %(resource_name)s in stack %(stack_identifier)s is "
63 "in %(resource_status)s status due to "
64 "'%(resource_status_reason)s'")
65
66
67class SSHTimeout(IntegrationException):
68 message = ("Connection to the %(host)s via SSH timed out.\n"
69 "User: %(user)s, Password: %(password)s")
70
71
72class SSHExecCommandFailed(IntegrationException):
73 """Raised when remotely executed command returns nonzero status."""
74 message = ("Command '%(command)s', exit status: %(exit_status)d, "
75 "Error:\n%(strerror)s")
76
77
78class ServerUnreachable(IntegrationException):
79 message = "The server is not reachable via the configured network"