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