94
class MissingCredentialError(OpenstackException):
94
class HeatException(Exception):
95
"""Base Heat Exception
97
To correctly use this class, inherit from it and define
98
a 'msg_fmt' property. That msg_fmt will get printf'd
99
with the keyword arguments provided to the constructor.
102
message = _("An unknown exception occurred.")
104
def __init__(self, **kwargs):
108
self.message = self.message % kwargs
110
exc_info = sys.exc_info()
111
#kwargs doesn't match a variable in the message
112
#log the issue and the kwargs
113
logger.exception(_('Exception in string format operation'))
114
for name, value in kwargs.iteritems():
115
logger.error("%s: %s" % (name, value))
117
if _FATAL_EXCEPTION_FORMAT_ERRORS:
118
raise exc_info[0], exc_info[1], exc_info[2]
121
return str(self.message)
124
class MissingCredentialError(HeatException):
95
125
message = _("Missing required credential: %(required)s")
98
class BadAuthStrategy(OpenstackException):
128
class BadAuthStrategy(HeatException):
99
129
message = _("Incorrect auth strategy, expected \"%(expected)s\" but "
100
130
"received \"%(received)s\"")
103
class AuthBadRequest(OpenstackException):
133
class AuthBadRequest(HeatException):
104
134
message = _("Connect error/bad request to Auth service at URL %(url)s.")
107
class AuthUrlNotFound(OpenstackException):
137
class AuthUrlNotFound(HeatException):
108
138
message = _("Auth service at URL %(url)s not found.")
111
class AuthorizationFailure(OpenstackException):
141
class AuthorizationFailure(HeatException):
112
142
message = _("Authorization failed.")
115
class NotAuthenticated(OpenstackException):
145
class NotAuthenticated(HeatException):
116
146
message = _("You are not authenticated.")
119
class Forbidden(OpenstackException):
149
class Forbidden(HeatException):
120
150
message = _("You are not authorized to complete this action.")
125
155
message = _("You are not authorized to complete this action.")
128
class Invalid(OpenstackException):
158
class Invalid(HeatException):
129
159
message = _("Data supplied was not valid: %(reason)s")
132
class AuthorizationRedirect(OpenstackException):
162
class AuthorizationRedirect(HeatException):
133
163
message = _("Redirecting to %(uri)s for authorization.")
136
class ClientConfigurationError(OpenstackException):
166
class ClientConfigurationError(HeatException):
137
167
message = _("There was an error configuring the client.")
140
class MultipleChoices(OpenstackException):
141
message = _("The request returned a 302 Multiple Choices. This generally "
142
"means that you have not included a version indicator in a "
143
"request URI.\n\nThe body of response returned:\n%(body)s")
146
class LimitExceeded(OpenstackException):
147
message = _("The request returned a 413 Request Entity Too Large. This "
148
"generally means that rate limiting or a quota threshold was "
149
"breached.\n\nThe response body:\n%(body)s")
151
def __init__(self, *args, **kwargs):
152
self.retry_after = (int(kwargs['retry']) if kwargs.get('retry')
154
super(LimitExceeded, self).__init__(*args, **kwargs)
157
class ServiceUnavailable(OpenstackException):
158
message = _("The request returned a 503 ServiceUnavilable. This "
159
"generally occurs on service overload or other transient "
162
def __init__(self, *args, **kwargs):
163
self.retry_after = (int(kwargs['retry']) if kwargs.get('retry')
165
super(ServiceUnavailable, self).__init__(*args, **kwargs)
168
class RequestUriTooLong(OpenstackException):
170
class RequestUriTooLong(HeatException):
169
171
message = _("The URI was too long.")
172
class ServerError(OpenstackException):
174
class ServerError(HeatException):
173
175
message = _("The request returned 500 Internal Server Error"
174
176
"\n\nThe response body:\n%(body)s")
177
class MaxRedirectsExceeded(OpenstackException):
179
class MaxRedirectsExceeded(HeatException):
178
180
message = _("Maximum redirects (%(redirects)s) was exceeded.")
181
class InvalidRedirect(OpenstackException):
183
class InvalidRedirect(HeatException):
182
184
message = _("Received invalid HTTP redirect.")
185
class NoServiceEndpoint(OpenstackException):
187
class NoServiceEndpoint(HeatException):
186
188
message = _("Response from Keystone does not contain a Heat endpoint.")
189
class RegionAmbiguity(OpenstackException):
191
class RegionAmbiguity(HeatException):
190
192
message = _("Multiple 'image' service matches for region %(region)s. This "
191
193
"generally means that a region is required and you have not "
195
class UserParameterMissing(OpenstackException):
197
class UserParameterMissing(HeatException):
196
198
message = _("The Parameter (%(key)s) was not provided.")
199
class UnknownUserParameter(OpenstackException):
201
class UnknownUserParameter(HeatException):
200
202
message = _("The Parameter (%(key)s) was not defined in template.")
203
class InvalidTemplateAttribute(OpenstackException):
205
class InvalidTemplateAttribute(HeatException):
204
206
message = _("The Referenced Attribute (%(resource)s %(key)s)"
205
207
" is incorrect.")
208
class InvalidTemplateReference(OpenstackException):
209
message = _("The specified reference (%(resource)s %(key)s)"
210
class InvalidTemplateReference(HeatException):
211
message = _("The specified reference \"%(resource)s\" (in %(key)s)"
210
212
" is incorrect.")
213
class UserKeyPairMissing(OpenstackException):
215
class UserKeyPairMissing(HeatException):
214
216
message = _("The Key (%(key_name)s) could not be found.")
217
class FlavorMissing(OpenstackException):
219
class FlavorMissing(HeatException):
218
220
message = _("The Flavor ID (%(flavor_id)s) could not be found.")
221
class ImageNotFound(OpenstackException):
223
class ImageNotFound(HeatException):
222
224
message = _("The Image (%(image_name)s) could not be found.")
225
class NoUniqueImageFound(OpenstackException):
227
class NoUniqueImageFound(HeatException):
226
228
message = _("Multiple images were found with name (%(image_name)s).")
229
class InvalidTenant(OpenstackException):
231
class InvalidTenant(HeatException):
230
232
message = _("Searching Tenant %(target)s "
231
233
"from Tenant %(actual)s forbidden.")
234
class StackNotFound(OpenstackException):
236
class StackNotFound(HeatException):
235
237
message = _("The Stack (%(stack_name)s) could not be found.")
238
class StackExists(OpenstackException):
240
class StackExists(HeatException):
239
241
message = _("The Stack (%(stack_name)s) already exists.")
242
class StackValidationFailed(OpenstackException):
244
class StackValidationFailed(HeatException):
243
245
message = _("%(message)s")
246
class ResourceNotFound(OpenstackException):
248
class ResourceNotFound(HeatException):
247
249
message = _("The Resource (%(resource_name)s) could not be found "
248
250
"in Stack %(stack_name)s.")
251
class ResourceTypeNotFound(OpenstackException):
253
class ResourceTypeNotFound(HeatException):
252
254
message = _("The Resource Type (%(type_name)s) could not be found.")
255
class ResourceNotAvailable(OpenstackException):
257
class ResourceNotAvailable(HeatException):
256
258
message = _("The Resource (%(resource_name)s) is not available.")
259
class PhysicalResourceNotFound(OpenstackException):
261
class PhysicalResourceNotFound(HeatException):
260
262
message = _("The Resource (%(resource_id)s) could not be found.")
263
class WatchRuleNotFound(OpenstackException):
265
class WatchRuleNotFound(HeatException):
264
266
message = _("The Watch Rule (%(watch_name)s) could not be found.")
267
class ActionInProgress(OpenstackException):
268
message = _("Stack %(stack_name)s already has an action (%(action)s) "
272
class ResourceFailure(OpenstackException):
269
class ResourceFailure(HeatException):
273
270
message = _("%(exc_type)s: %(message)s")
275
272
def __init__(self, exception, resource, action=None):
283
280
message=str(exception))
286
class NotSupported(OpenstackException):
283
class NotSupported(HeatException):
287
284
message = _("%(feature)s is not supported.")
290
class ResourcePropertyConflict(OpenstackException):
287
class ResourcePropertyConflict(HeatException):
291
288
message = _('Cannot define the following properties at the same time: %s.')
293
290
def __init__(self, *args):
294
291
self.message = self.message % ", ".join(args)
295
292
super(ResourcePropertyConflict, self).__init__()
295
class HTTPExceptionDisguise(Exception):
296
"""Disguises HTTP exceptions so they can be handled by the webob fault
297
application in the wsgi pipeline.
300
def __init__(self, exception):
302
self.tb = sys.exc_info()[2]
305
class TemplateTooBig(HeatException):
306
message = _('Template exceeds maximum allowed size.')
309
class EgressRuleNotAllowed(HeatException):
310
message = _("Egress rules are only allowed when "
311
"Neutron is used and the 'VpcId' property is set.")
314
class Error(Exception):
315
def __init__(self, message=None):
316
super(Error, self).__init__(message)
319
class NotFound(Error):
323
class InvalidContentType(HeatException):
324
message = "Invalid content type %(content_type)s"
327
class StackRecursionLimitReached(HeatException):
328
message = _("Recursion depth exceeds %d.")
330
def __init__(self, recursion_depth):
331
self.message = self.message % recursion_depth
332
super(StackRecursionLimitReached, self).__init__()