1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 """Ganeti exception handling.
32
33 """
34
35 from ganeti import constants
36
37
38 ECODE_RESOLVER = constants.ERRORS_ECODE_RESOLVER
39 ECODE_NORES = constants.ERRORS_ECODE_NORES
40 ECODE_TEMP_NORES = constants.ERRORS_ECODE_TEMP_NORES
41 ECODE_INVAL = constants.ERRORS_ECODE_INVAL
42 ECODE_STATE = constants.ERRORS_ECODE_STATE
43 ECODE_NOENT = constants.ERRORS_ECODE_NOENT
44 ECODE_EXISTS = constants.ERRORS_ECODE_EXISTS
45 ECODE_NOTUNIQUE = constants.ERRORS_ECODE_NOTUNIQUE
46 ECODE_FAULT = constants.ERRORS_ECODE_FAULT
47 ECODE_ENVIRON = constants.ERRORS_ECODE_ENVIRON
48 ECODE_ALL = constants.ERRORS_ECODE_ALL
49
50
52 """Base exception for Ganeti.
53
54 """
55
56
58 """Lock error exception.
59
60 This signifies problems in the locking subsystem.
61
62 """
63
64
66 """PID file is already locked by another process.
67
68 """
69
70
72 """Hypervisor-related exception.
73
74 This is raised in case we can't communicate with the hypervisor
75 properly.
76
77 """
78
79
81 """Hotplug-related exception.
82
83 This is raised in case a hotplug action fails or is not supported.
84 It is currently used only by KVM hypervisor.
85
86 """
87
88
90 """Programming-related error.
91
92 This is raised in cases we determine that the calling conventions
93 have been violated, meaning we got some desynchronisation between
94 parts of our code. It signifies a real programming bug.
95
96 """
97
98
100 """Block-device related exception.
101
102 This is raised in case we can't setup the instance's block devices
103 properly.
104
105 """
106
107
109 """Configuration related exception.
110
111 Things like having an instance with a primary node that doesn't
112 exist in the config or such raise this exception.
113
114 """
115
116
118 """Version mismatch in the configuration file.
119
120 The error has two arguments: the expected and the actual found
121 version.
122
123 """
124
125
127 """Errors related to IP address pools.
128
129 """
130
131
133 """Errors reserving a resource.
134
135 """
136
137
139 """Programming-related error on remote call.
140
141 This is raised when an unhandled error occurs in a call to a
142 remote node. It usually signifies a real programming bug.
143
144 """
145
146
148 """Error authenticating a remote message.
149
150 This is raised when the hmac signature on a message doesn't verify correctly
151 to the message itself. It can happen because of network unreliability or
152 because of spurious traffic.
153
154 """
155
156
158 """A passed parameter to a command is invalid.
159
160 This is raised when the parameter passed to a request function is
161 invalid. Correct code should have verified this before passing the
162 request structure.
163
164 The argument to this exception should be the parameter name.
165
166 """
167
168
170 """The iallocation results fails validation.
171
172 """
173
174
176 """Prerequisites for the OpCode are not fulfilled.
177
178 This exception has two arguments: an error message, and one of the
179 ECODE_* codes.
180
181 """
182
183
185 """Error during OpCode execution.
186
187 """
188
189
191 """Issue with OpCode result.
192
193 """
194
195
197 """Error during the creation of a device.
198
199 This exception should contain the list of the devices actually created
200 up to now, in the form of pairs (node, device)
201
202 """
203 - def __init__(self, message, created_devices):
207
210
211
213 """Unknown opcode submitted.
214
215 This signifies a mismatch between the definitions on the client and
216 server side.
217
218 """
219
220
222 """Submitted job lost.
223
224 The job was submitted but it cannot be found in the current job
225 list.
226
227 """
228
229
231 """Job file could not be properly decoded/restored.
232
233 """
234
235
237 """Host name cannot be resolved.
238
239 This is not a normal situation for Ganeti, as we rely on having a
240 working resolver.
241
242 The non-resolvable hostname is available as the first element of the
243 args tuple; the other two elements of the tuple are the first two
244 args of the socket.gaierror exception (error code and description).
245
246 """
247
248
250 """A generic hook failure.
251
252 This signifies usually a setup misconfiguration.
253
254 """
255
256
258 """A required hook has failed.
259
260 This caused an abort of the operation in the initial phase. This
261 exception always has an attribute args which is a list of tuples of:
262 - node: the source node on which this hooks has failed
263 - script: the name of the script which aborted the run
264
265 """
266
267
269 """Unable to parse size unit.
270
271 """
272
273
275 """Generic parse error.
276
277 Raised when unable to parse user input.
278
279 """
280
281
283 """Unable to enforce data type.
284
285 """
286
287
289 """Invalid X509 certificate.
290
291 This error has two arguments: the certificate filename and the error cause.
292
293 """
294
295
297 """Generic tag error.
298
299 The argument to this exception will show the exact error.
300
301 """
302
303
305 """External command error.
306
307 """
308
309
311 """Storage-related exception.
312
313 """
314
315
317 """Error raised when there is a failure setting up an inotify watcher.
318
319 """
320
321
323 """Signal Ganeti that it must quit.
324
325 This is not necessarily an error (and thus not a subclass of
326 GenericError), but it's an exceptional circumstance and it is thus
327 treated. This exception should be instantiated with two values. The
328 first one will specify the return code to the caller, and the second
329 one will be the returned result (either as an error or as a normal
330 result). Usually only the leave cluster rpc call should return
331 status True (as there it's expected we quit), every other call will
332 return status False (as a critical error was encountered).
333
334 Examples::
335
336 # Return a result of "True" to the caller, but quit ganeti afterwards
337 raise QuitGanetiException(True, None)
338 # Send an error to the caller, and quit ganeti
339 raise QuitGanetiException(False, "Fatal safety violation, shutting down")
340
341 """
342
343
345 """Job queue error.
346
347 """
348
349
351 """Job queue is marked for drain error.
352
353 This is raised when a job submission attempt is made but the queue
354 is marked for drain.
355
356 """
357
358
360 """Job queue full error.
361
362 Raised when job queue size reached its hard limit.
363
364 """
365
366
368 """A magic fourcc error in Ganeti confd.
369
370 Errors processing the fourcc in ganeti confd datagrams.
371
372 """
373
374
376 """A magic fourcc error in Ganeti confd.
377
378 Errors in the confd client library.
379
380 """
381
382
384 """UDP payload too big.
385
386 """
387
388
390 """python ctypes module is not found in the system.
391
392 """
393
394
396 """Generic IP address error.
397
398 """
399
400
402 """LUXI error.
403
404 """
405
406
408 """Error while parsing query filter.
409
410 This exception must be instantiated with two values. The first one is a
411 string with an error description, the second one is an instance of a subclass
412 of C{pyparsing.ParseBaseException} (used to display the exact error
413 location).
414
415 """
417 """Returns a list of strings with details about the error.
418
419 """
420 try:
421 (_, inner) = self.args
422 except IndexError:
423 return None
424
425 return [str(inner.line),
426 (" " * (inner.column - 1)) + "^",
427 str(inner)]
428
429
431 """Exception containing results from RAPI test utilities.
432
433 """
434
435
437 """Error from file storage path validation.
438
439 """
440
441
442
443
444
446 """Return the class of an exception.
447
448 Given the class name, return the class itself.
449
450 @type name: str
451 @param name: the exception name
452 @rtype: class
453 @return: the actual class, or None if not found
454
455 """
456 item = globals().get(name, None)
457 if item is not None:
458 if not (isinstance(item, type(Exception)) and
459 issubclass(item, GenericError)):
460 item = None
461 return item
462
463
465 """Encodes an exception into a format that L{MaybeRaise} will recognise.
466
467 The passed L{err} argument will be formatted as a tuple (exception
468 name, arguments) that the MaybeRaise function will recognise.
469
470 @type err: GenericError child
471 @param err: usually a child of GenericError (but any exception
472 will be accepted)
473 @rtype: tuple
474 @return: tuple of (exception name, exception arguments)
475
476 """
477 return (err.__class__.__name__, err.args)
478
479
481 """If this looks like an encoded Ganeti exception, return it.
482
483 This function tries to parse the passed argument and if it looks
484 like an encoding done by EncodeException, it will return the class
485 object and arguments.
486
487 """
488 tlt = (tuple, list)
489 if (isinstance(result, tlt) and len(result) == 2 and
490 isinstance(result[1], tlt)):
491
492 errcls = GetErrorClass(result[0])
493 if errcls:
494 return (errcls, tuple(result[1]))
495
496 return None
497
498
500 """If this looks like an encoded Ganeti exception, raise it.
501
502 This function tries to parse the passed argument and if it looks
503 like an encoding done by EncodeException, it will re-raise it.
504
505 """
506 error = GetEncodedError(result)
507 if error:
508 (errcls, args) = error
509
510 raise errcls(*args)
511