blob: b092fd062f8d01d623882b962494eaec0cc255f9 [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):
Peter Razumovskyf0ac9582015-09-24 16:49:03 +030015 """Base Tempest Exception.
Steve Baker450aa7f2014-08-25 10:37:27 +120016
17 To correctly use this class, inherit from it and define
18 a 'message' property. That message will get printf'd
19 with the keyword arguments provided to the constructor.
20 """
21 message = "An unknown exception occurred"
22
23 def __init__(self, *args, **kwargs):
24 super(IntegrationException, self).__init__()
25 try:
26 self._error_string = self.message % kwargs
27 except Exception:
28 # at least get the core message out if something happened
29 self._error_string = self.message
30 if len(args) > 0:
31 # If there is a non-kwarg parameter, assume it's the error
32 # message or reason description and tack it on to the end
33 # of the exception message
34 # Convert all arguments into their string representations...
35 args = ["%s" % arg for arg in args]
36 self._error_string = (self._error_string +
37 "\nDetails: %s" % '\n'.join(args))
38
39 def __str__(self):
40 return self._error_string
41
42
43class InvalidCredentials(IntegrationException):
44 message = "Invalid Credentials"
45
46
47class TimeoutException(IntegrationException):
48 message = "Request timed out"
49
50
51class BuildErrorException(IntegrationException):
52 message = "Server %(server_id)s failed to build and is in ERROR status"
53
54
55class StackBuildErrorException(IntegrationException):
56 message = ("Stack %(stack_identifier)s is in %(stack_status)s status "
57 "due to '%(stack_status_reason)s'")
58
59
60class StackResourceBuildErrorException(IntegrationException):
61 message = ("Resource %(resource_name)s in stack %(stack_identifier)s is "
62 "in %(resource_status)s status due to "
63 "'%(resource_status_reason)s'")
64
65
66class SSHTimeout(IntegrationException):
67 message = ("Connection to the %(host)s via SSH timed out.\n"
68 "User: %(user)s, Password: %(password)s")
69
70
71class SSHExecCommandFailed(IntegrationException):
72 """Raised when remotely executed command returns nonzero status."""
73 message = ("Command '%(command)s', exit status: %(exit_status)d, "
74 "Error:\n%(strerror)s")
75
76
77class ServerUnreachable(IntegrationException):
78 message = "The server is not reachable via the configured network"