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
26 """Base exception for Ganeti.
27
28 """
29 pass
30
31
33 """LVM-related exception.
34
35 This exception codifies problems with LVM setup.
36
37 """
38 pass
39
40
42 """Lock error exception.
43
44 This signifies problems in the locking subsystem.
45
46 """
47 pass
48
49
51 """Hypervisor-related exception.
52
53 This is raised in case we can't communicate with the hypervisor
54 properly.
55
56 """
57 pass
58
59
61 """Programming-related error.
62
63 This is raised in cases we determine that the calling conventions
64 have been violated, meaning we got some desynchronisation between
65 parts of our code. It signifies a real programming bug.
66
67 """
68 pass
69
70
72 """Block-device related exception.
73
74 This is raised in case we can't setup the instance's block devices
75 properly.
76
77 """
78 pass
79
80
82 """Configuration related exception.
83
84 Things like having an instance with a primary node that doesn't
85 exist in the config or such raise this exception.
86
87 """
88 pass
89
90
92 """Programming-related error on remote call.
93
94 This is raised when an unhandled error occurs in a call to a
95 remote node. It usually signifies a real programming bug.
96
97 """
98 pass
99
100
102 """Missing OS on node.
103
104 This is raised when an OS exists on the master (or is otherwise
105 requested to the code) but not on the target node.
106
107 This exception has three arguments:
108 - the name of the os
109 - the source directory, if any
110 - the reason why we consider this an invalid OS (text of error message)
111
112 """
113
114
116 """A passed parameter to a command is invalid.
117
118 This is raised when the parameter passed to a request function is
119 invalid. Correct code should have verified this before passing the
120 request structure.
121
122 The argument to this exception should be the parameter name.
123
124 """
125 pass
126
127
129 """Prerequisites for the OpCode are not fulfilled.
130
131 """
132
133
135 """Error during OpCode execution.
136
137 """
138
139
141 """Error during OpCode execution, action can be retried.
142
143 """
144
145
147 """Unknown opcode submitted.
148
149 This signifies a mismatch between the definitions on the client and
150 server side.
151
152 """
153
154
156 """Submitted job lost.
157
158 The job was submitted but it cannot be found in the current job
159 list.
160
161 """
162
163
165 """Host name cannot be resolved.
166
167 This is not a normal situation for Ganeti, as we rely on having a
168 working resolver.
169
170 The non-resolvable hostname is available as the first element of the
171 args tuple; the other two elements of the tuple are the first two
172 args of the socket.gaierror exception (error code and description).
173
174 """
175
176
178 """A generic hook failure.
179
180 This signifies usually a setup misconfiguration.
181
182 """
183
184
186 """A required hook has failed.
187
188 This caused an abort of the operation in the initial phase. This
189 exception always has an attribute args which is a list of tuples of:
190 - node: the source node on which this hooks has failed
191 - script: the name of the script which aborted the run
192
193 """
194
195
197 """Unable to parse size unit.
198
199 """
200
202 """Unable to enforce data type.
203
204 """
205
207 """Invalid SSH key.
208
209 """
210
211
213 """Generic tag error.
214
215 The argument to this exception will show the exact error.
216
217 """
218
219
221 """External command error.
222
223 """
224
225
227 """Signal that Ganeti that it must quit.
228
229 This is not necessarily an error (and thus not a subclass of GenericError),
230 but it's an exceptional circumstance and it is thus treated. This instance
231 should be instantiated with two values. The first one will specify whether an
232 error should returned to the caller, and the second one will be the returned
233 result (either as an error or as a normal result).
234
235 Examples::
236
237 # Return a result of "True" to the caller, but quit ganeti afterwards
238 raise QuitGanetiException(False, True)
239 # Send an error to the caller, and quit ganeti
240 raise QuitGanetiException(True, "Fatal safety violation, shutting down")
241
242 """
243
244
246 """Job queue error.
247
248 """
249
250
252 """Job queue is marked for drain error.
253
254 This is raised when a job submission attempt is made but the queue
255 is marked for drain.
256
257 """
258
259
261 """Job queue full error.
262
263 Raised when job queue size reached its hard limit.
264
265 """
266
267
268
269
270
272 """Return the class of an exception.
273
274 Given the class name, return the class itself.
275
276 @type name: str
277 @param name: the exception name
278 @rtype: class
279 @return: the actual class, or None if not found
280
281 """
282 item = globals().get(name, None)
283 if item is not None:
284 if not (isinstance(item, type(Exception)) and
285 issubclass(item, GenericError)):
286 item = None
287 return item
288
289
291 """Encodes an exception into a format that L{MaybeRaise} will recognise.
292
293 The passed L{err} argument will be formatted as a tuple (exception
294 name, arguments) that the MaybeRaise function will recognise.
295
296 @type err: GenericError child
297 @param err: usually a child of GenericError (but any exception
298 will be accepted)
299 @rtype: tuple
300 @return: tuple of (exception name, exception arguments)
301
302 """
303 return (err.__class__.__name__, err.args)
304
305
307 """If this looks like an encoded Ganeti exception, raise it.
308
309 This function tries to parse the passed argument and if it looks
310 like an encoding done by EncodeException, it will re-raise it.
311
312 """
313 tlt = (tuple, list)
314 if (isinstance(result, tlt) and len(result) == 2 and
315 isinstance(result[1], tlt)):
316
317 err_class = GetErrorClass(result[0])
318 if err_class is not None:
319 raise err_class, tuple(result[1])
320