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 """Errors reserving a resource.
115
116 """
117
118
120 """Programming-related error on remote call.
121
122 This is raised when an unhandled error occurs in a call to a
123 remote node. It usually signifies a real programming bug.
124
125 """
126 pass
127
128
130 """Error authenticating a remote message.
131
132 This is raised when the hmac signature on a message doesn't verify correctly
133 to the message itself. It can happen because of network unreliability or
134 because of spurious traffic.
135
136 """
137 pass
138
139
141 """A passed parameter to a command is invalid.
142
143 This is raised when the parameter passed to a request function is
144 invalid. Correct code should have verified this before passing the
145 request structure.
146
147 The argument to this exception should be the parameter name.
148
149 """
150 pass
151
152
154 """Prerequisites for the OpCode are not fulfilled.
155
156 This exception will have either one or two arguments. For the
157 two-argument construction, the second argument should be one of the
158 ECODE_* codes.
159
160 """
161
162
164 """Error during OpCode execution.
165
166 """
167
168
170 """Unknown opcode submitted.
171
172 This signifies a mismatch between the definitions on the client and
173 server side.
174
175 """
176
177
179 """Submitted job lost.
180
181 The job was submitted but it cannot be found in the current job
182 list.
183
184 """
185
186
188 """Job file could not be properly decoded/restored.
189
190 """
191
192
194 """Host name cannot be resolved.
195
196 This is not a normal situation for Ganeti, as we rely on having a
197 working resolver.
198
199 The non-resolvable hostname is available as the first element of the
200 args tuple; the other two elements of the tuple are the first two
201 args of the socket.gaierror exception (error code and description).
202
203 """
204
205
207 """A generic hook failure.
208
209 This signifies usually a setup misconfiguration.
210
211 """
212
213
215 """A required hook has failed.
216
217 This caused an abort of the operation in the initial phase. This
218 exception always has an attribute args which is a list of tuples of:
219 - node: the source node on which this hooks has failed
220 - script: the name of the script which aborted the run
221
222 """
223
224
226 """Unable to parse size unit.
227
228 """
229
230
232 """Generic parse error.
233
234 Raised when unable to parse user input.
235
236 """
237
238
240 """Unable to enforce data type.
241
242 """
243
244
246 """Invalid SSH key.
247
248 """
249
250
252 """Generic tag error.
253
254 The argument to this exception will show the exact error.
255
256 """
257
258
260 """External command error.
261
262 """
263
264
266 """Storage-related exception.
267
268 """
269
270
272 """Error raised when there is a failure setting up an inotify watcher.
273
274 """
275
276
278 """Signal that Ganeti that it must quit.
279
280 This is not necessarily an error (and thus not a subclass of
281 GenericError), but it's an exceptional circumstance and it is thus
282 treated. This instance should be instantiated with two values. The
283 first one will specify the return code to the caller, and the second
284 one will be the returned result (either as an error or as a normal
285 result). Usually only the leave cluster rpc call should return
286 status True (as there it's expected we quit), every other call will
287 return status False (as a critical error was encountered).
288
289 Examples::
290
291 # Return a result of "True" to the caller, but quit ganeti afterwards
292 raise QuitGanetiException(True, None)
293 # Send an error to the caller, and quit ganeti
294 raise QuitGanetiException(False, "Fatal safety violation, shutting down")
295
296 """
297
298
300 """Job queue error.
301
302 """
303
304
306 """Job queue is marked for drain error.
307
308 This is raised when a job submission attempt is made but the queue
309 is marked for drain.
310
311 """
312
313
315 """Job queue full error.
316
317 Raised when job queue size reached its hard limit.
318
319 """
320
321
323 """A request error in Ganeti confd.
324
325 Events that should make confd abort the current request and proceed serving
326 different ones.
327
328 """
329
330
332 """A magic fourcc error in Ganeti confd.
333
334 Errors processing the fourcc in ganeti confd datagrams.
335
336 """
337
338
340 """A magic fourcc error in Ganeti confd.
341
342 Errors in the confd client library.
343
344 """
345
346
348 """UDP payload too big.
349
350 """
351
352
354 """python ctypes module is not found in the system.
355
356 """
357
358
359
360
361
363 """Return the class of an exception.
364
365 Given the class name, return the class itself.
366
367 @type name: str
368 @param name: the exception name
369 @rtype: class
370 @return: the actual class, or None if not found
371
372 """
373 item = globals().get(name, None)
374 if item is not None:
375 if not (isinstance(item, type(Exception)) and
376 issubclass(item, GenericError)):
377 item = None
378 return item
379
380
382 """Encodes an exception into a format that L{MaybeRaise} will recognise.
383
384 The passed L{err} argument will be formatted as a tuple (exception
385 name, arguments) that the MaybeRaise function will recognise.
386
387 @type err: GenericError child
388 @param err: usually a child of GenericError (but any exception
389 will be accepted)
390 @rtype: tuple
391 @return: tuple of (exception name, exception arguments)
392
393 """
394 return (err.__class__.__name__, err.args)
395
396
398 """If this looks like an encoded Ganeti exception, return it.
399
400 This function tries to parse the passed argument and if it looks
401 like an encoding done by EncodeException, it will return the class
402 object and arguments.
403
404 """
405 tlt = (tuple, list)
406 if (isinstance(result, tlt) and len(result) == 2 and
407 isinstance(result[1], tlt)):
408
409 errcls = GetErrorClass(result[0])
410 if errcls:
411 return (errcls, tuple(result[1]))
412
413 return None
414
415
417 """If this looks like an encoded Ganeti exception, raise it.
418
419 This function tries to parse the passed argument and if it looks
420 like an encoding done by EncodeException, it will re-raise it.
421
422 """
423 error = GetEncodedError(result)
424 if error:
425 (errcls, args) = error
426 raise errcls, args
427