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 """Error reported by configuration verification
128
129 The error has two arguments: the main error message and a list of errors
130 found.
131
132 """
133
134
136 """Errors related to IP address pools.
137
138 """
139
140
142 """Errors reserving a resource.
143
144 """
145
146
148 """Programming-related error on remote call.
149
150 This is raised when an unhandled error occurs in a call to a
151 remote node. It usually signifies a real programming bug.
152
153 """
154
155
157 """Error authenticating a remote message.
158
159 This is raised when the hmac signature on a message doesn't verify correctly
160 to the message itself. It can happen because of network unreliability or
161 because of spurious traffic.
162
163 """
164
165
167 """A passed parameter to a command is invalid.
168
169 This is raised when the parameter passed to a request function is
170 invalid. Correct code should have verified this before passing the
171 request structure.
172
173 The argument to this exception should be the parameter name.
174
175 """
176
177
179 """The iallocation results fails validation.
180
181 """
182
183
185 """Prerequisites for the OpCode are not fulfilled.
186
187 This exception has two arguments: an error message, and one of the
188 ECODE_* codes.
189
190 """
191
192
194 """Error during OpCode execution.
195
196 """
197
198
200 """Issue with OpCode result.
201
202 """
203
204
206 """This opcode does not support retries
207
208 """
209
210
212 """Error during the creation of a device.
213
214 This exception should contain the list of the devices actually created
215 up to now, in the form of pairs (node, device)
216
217 """
218 - def __init__(self, message, created_devices):
222
225
226
228 """Unknown opcode submitted.
229
230 This signifies a mismatch between the definitions on the client and
231 server side.
232
233 """
234
235
237 """Submitted job lost.
238
239 The job was submitted but it cannot be found in the current job
240 list.
241
242 """
243
244
246 """Job file could not be properly decoded/restored.
247
248 """
249
250
252 """Host name cannot be resolved.
253
254 This is not a normal situation for Ganeti, as we rely on having a
255 working resolver.
256
257 The non-resolvable hostname is available as the first element of the
258 args tuple; the other two elements of the tuple are the first two
259 args of the socket.gaierror exception (error code and description).
260
261 """
262
263
265 """A generic hook failure.
266
267 This signifies usually a setup misconfiguration.
268
269 """
270
271
273 """A required hook has failed.
274
275 This caused an abort of the operation in the initial phase. This
276 exception always has an attribute args which is a list of tuples of:
277 - node: the source node on which this hooks has failed
278 - script: the name of the script which aborted the run
279
280 """
281
282
284 """Unable to parse size unit.
285
286 """
287
288
290 """Generic parse error.
291
292 Raised when unable to parse user input.
293
294 """
295
296
298 """Unable to enforce data type.
299
300 """
301
302
304 """Invalid X509 certificate.
305
306 This error has two arguments: the certificate filename and the error cause.
307
308 """
309
310
312 """Generic tag error.
313
314 The argument to this exception will show the exact error.
315
316 """
317
318
320 """External command error.
321
322 """
323
324
326 """Storage-related exception.
327
328 """
329
330
332 """Error raised when there is a failure setting up an inotify watcher.
333
334 """
335
336
338 """Signal Ganeti that it must quit.
339
340 This is not necessarily an error (and thus not a subclass of
341 GenericError), but it's an exceptional circumstance and it is thus
342 treated. This exception should be instantiated with two values. The
343 first one will specify the return code to the caller, and the second
344 one will be the returned result (either as an error or as a normal
345 result). Usually only the leave cluster rpc call should return
346 status True (as there it's expected we quit), every other call will
347 return status False (as a critical error was encountered).
348
349 Examples::
350
351 # Return a result of "True" to the caller, but quit ganeti afterwards
352 raise QuitGanetiException(True, None)
353 # Send an error to the caller, and quit ganeti
354 raise QuitGanetiException(False, "Fatal safety violation, shutting down")
355
356 """
357
358
360 """Job queue error.
361
362 """
363
364
366 """Job queue is marked for drain error.
367
368 This is raised when a job submission attempt is made but the queue
369 is marked for drain.
370
371 """
372
373
375 """Job queue full error.
376
377 Raised when job queue size reached its hard limit.
378
379 """
380
381
383 """A magic fourcc error in Ganeti confd.
384
385 Errors processing the fourcc in ganeti confd datagrams.
386
387 """
388
389
391 """A magic fourcc error in Ganeti confd.
392
393 Errors in the confd client library.
394
395 """
396
397
399 """UDP payload too big.
400
401 """
402
403
405 """python ctypes module is not found in the system.
406
407 """
408
409
411 """Generic IP address error.
412
413 """
414
415
417 """LUXI error.
418
419 """
420
421
423 """Error while parsing query filter.
424
425 This exception must be instantiated with two values. The first one is a
426 string with an error description, the second one is an instance of a subclass
427 of C{pyparsing.ParseBaseException} (used to display the exact error
428 location).
429
430 """
432 """Returns a list of strings with details about the error.
433
434 """
435 try:
436 (_, inner) = self.args
437 except IndexError:
438 return None
439
440 return [str(inner.line),
441 (" " * (inner.column - 1)) + "^",
442 str(inner)]
443
444
446 """Exception containing results from RAPI test utilities.
447
448 """
449
450
452 """Error from file storage path validation.
453
454 """
455
456
458 """Error from updating the SSH setup.
459
460 """
461
462
464 """Error in PAM remote API authenticator initialization.
465
466 """
467
468
469
470
471
473 """Return the class of an exception.
474
475 Given the class name, return the class itself.
476
477 @type name: str
478 @param name: the exception name
479 @rtype: class
480 @return: the actual class, or None if not found
481
482 """
483 item = globals().get(name, None)
484 if item is not None:
485 if not (isinstance(item, type(Exception)) and
486 issubclass(item, GenericError)):
487 item = None
488 return item
489
490
492 """Encodes an exception into a format that L{MaybeRaise} will recognise.
493
494 The passed L{err} argument will be formatted as a tuple (exception
495 name, arguments) that the MaybeRaise function will recognise.
496
497 @type err: GenericError child
498 @param err: usually a child of GenericError (but any exception
499 will be accepted)
500 @rtype: tuple
501 @return: tuple of (exception name, exception arguments)
502
503 """
504 return (err.__class__.__name__, err.args)
505
506
508 """If this looks like an encoded Ganeti exception, return it.
509
510 This function tries to parse the passed argument and if it looks
511 like an encoding done by EncodeException, it will return the class
512 object and arguments.
513
514 """
515 tlt = (tuple, list)
516 if (isinstance(result, tlt) and len(result) == 2 and
517 isinstance(result[1], tlt)):
518
519 errcls = GetErrorClass(result[0])
520 if errcls:
521 return (errcls, tuple(result[1]))
522
523 return None
524
525
527 """If this looks like an encoded Ganeti exception, raise it.
528
529 This function tries to parse the passed argument and if it looks
530 like an encoding done by EncodeException, it will re-raise it.
531
532 """
533 error = GetEncodedError(result)
534 if error:
535 (errcls, args) = error
536
537 raise errcls(*args)
538