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
48 """Base exception for Ganeti.
49
50 """
51 pass
52
53
55 """LVM-related exception.
56
57 This exception codifies problems with LVM setup.
58
59 """
60 pass
61
62
64 """Lock error exception.
65
66 This signifies problems in the locking subsystem.
67
68 """
69 pass
70
71
73 """Hypervisor-related exception.
74
75 This is raised in case we can't communicate with the hypervisor
76 properly.
77
78 """
79 pass
80
81
83 """Programming-related error.
84
85 This is raised in cases we determine that the calling conventions
86 have been violated, meaning we got some desynchronisation between
87 parts of our code. It signifies a real programming bug.
88
89 """
90 pass
91
92
94 """Block-device related exception.
95
96 This is raised in case we can't setup the instance's block devices
97 properly.
98
99 """
100 pass
101
102
104 """Configuration related exception.
105
106 Things like having an instance with a primary node that doesn't
107 exist in the config or such raise this exception.
108
109 """
110 pass
111
112
114 """Version mismatch in the configuration file.
115
116 The error has two arguments: the expected and the actual found
117 version.
118
119 """
120 pass
121
122
124 """Errors reserving a resource.
125
126 """
127
128
130 """Programming-related error on remote call.
131
132 This is raised when an unhandled error occurs in a call to a
133 remote node. It usually signifies a real programming bug.
134
135 """
136 pass
137
138
140 """Error authenticating a remote message.
141
142 This is raised when the hmac signature on a message doesn't verify correctly
143 to the message itself. It can happen because of network unreliability or
144 because of spurious traffic.
145
146 """
147 pass
148
149
151 """A passed parameter to a command is invalid.
152
153 This is raised when the parameter passed to a request function is
154 invalid. Correct code should have verified this before passing the
155 request structure.
156
157 The argument to this exception should be the parameter name.
158
159 """
160 pass
161
162
164 """Prerequisites for the OpCode are not fulfilled.
165
166 This exception will have either one or two arguments. For the
167 two-argument construction, the second argument should be one of the
168 ECODE_* codes.
169
170 """
171
172
174 """Error during OpCode execution.
175
176 """
177
178
180 """Unknown opcode submitted.
181
182 This signifies a mismatch between the definitions on the client and
183 server side.
184
185 """
186
187
189 """Submitted job lost.
190
191 The job was submitted but it cannot be found in the current job
192 list.
193
194 """
195
196
198 """Job file could not be properly decoded/restored.
199
200 """
201
202
204 """Host name cannot be resolved.
205
206 This is not a normal situation for Ganeti, as we rely on having a
207 working resolver.
208
209 The non-resolvable hostname is available as the first element of the
210 args tuple; the other two elements of the tuple are the first two
211 args of the socket.gaierror exception (error code and description).
212
213 """
214
215
217 """A generic hook failure.
218
219 This signifies usually a setup misconfiguration.
220
221 """
222
223
225 """A required hook has failed.
226
227 This caused an abort of the operation in the initial phase. This
228 exception always has an attribute args which is a list of tuples of:
229 - node: the source node on which this hooks has failed
230 - script: the name of the script which aborted the run
231
232 """
233
234
236 """Unable to parse size unit.
237
238 """
239
240
242 """Generic parse error.
243
244 Raised when unable to parse user input.
245
246 """
247
248
250 """Unable to enforce data type.
251
252 """
253
254
256 """Invalid SSH key.
257
258 """
259
260
262 """Generic tag error.
263
264 The argument to this exception will show the exact error.
265
266 """
267
268
270 """External command error.
271
272 """
273
274
276 """Storage-related exception.
277
278 """
279
280
282 """Error raised when there is a failure setting up an inotify watcher.
283
284 """
285
286
288 """Signal that Ganeti that it must quit.
289
290 This is not necessarily an error (and thus not a subclass of
291 GenericError), but it's an exceptional circumstance and it is thus
292 treated. This instance should be instantiated with two values. The
293 first one will specify the return code to the caller, and the second
294 one will be the returned result (either as an error or as a normal
295 result). Usually only the leave cluster rpc call should return
296 status True (as there it's expected we quit), every other call will
297 return status False (as a critical error was encountered).
298
299 Examples::
300
301 # Return a result of "True" to the caller, but quit ganeti afterwards
302 raise QuitGanetiException(True, None)
303 # Send an error to the caller, and quit ganeti
304 raise QuitGanetiException(False, "Fatal safety violation, shutting down")
305
306 """
307
308
310 """Job queue error.
311
312 """
313
314
316 """Job queue is marked for drain error.
317
318 This is raised when a job submission attempt is made but the queue
319 is marked for drain.
320
321 """
322
323
325 """Job queue full error.
326
327 Raised when job queue size reached its hard limit.
328
329 """
330
331
333 """A request error in Ganeti confd.
334
335 Events that should make confd abort the current request and proceed serving
336 different ones.
337
338 """
339
340
342 """A magic fourcc error in Ganeti confd.
343
344 Errors processing the fourcc in ganeti confd datagrams.
345
346 """
347
348
350 """A magic fourcc error in Ganeti confd.
351
352 Errors in the confd client library.
353
354 """
355
356
358 """UDP payload too big.
359
360 """
361
362
364 """python ctypes module is not found in the system.
365
366 """
367
368
370 """Generic IP address error.
371
372 """
373
374
376 """LUXI error.
377
378 """
379
380
381
382
383
385 """Return the class of an exception.
386
387 Given the class name, return the class itself.
388
389 @type name: str
390 @param name: the exception name
391 @rtype: class
392 @return: the actual class, or None if not found
393
394 """
395 item = globals().get(name, None)
396 if item is not None:
397 if not (isinstance(item, type(Exception)) and
398 issubclass(item, GenericError)):
399 item = None
400 return item
401
402
404 """Encodes an exception into a format that L{MaybeRaise} will recognise.
405
406 The passed L{err} argument will be formatted as a tuple (exception
407 name, arguments) that the MaybeRaise function will recognise.
408
409 @type err: GenericError child
410 @param err: usually a child of GenericError (but any exception
411 will be accepted)
412 @rtype: tuple
413 @return: tuple of (exception name, exception arguments)
414
415 """
416 return (err.__class__.__name__, err.args)
417
418
420 """If this looks like an encoded Ganeti exception, return it.
421
422 This function tries to parse the passed argument and if it looks
423 like an encoding done by EncodeException, it will return the class
424 object and arguments.
425
426 """
427 tlt = (tuple, list)
428 if (isinstance(result, tlt) and len(result) == 2 and
429 isinstance(result[1], tlt)):
430
431 errcls = GetErrorClass(result[0])
432 if errcls:
433 return (errcls, tuple(result[1]))
434
435 return None
436
437
439 """If this looks like an encoded Ganeti exception, raise it.
440
441 This function tries to parse the passed argument and if it looks
442 like an encoding done by EncodeException, it will re-raise it.
443
444 """
445 error = GetEncodedError(result)
446 if error:
447 (errcls, args) = error
448 raise errcls, args
449