root / lib / errors.py @ 0500f6fd
History | View | Annotate | Download (11.4 kB)
1 | 2f31098c | Iustin Pop | #
|
---|---|---|---|
2 | a8083063 | Iustin Pop | #
|
3 | a8083063 | Iustin Pop | |
4 | 98dfcaff | Iustin Pop | # Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012 Google Inc.
|
5 | a8083063 | Iustin Pop | #
|
6 | a8083063 | Iustin Pop | # This program is free software; you can redistribute it and/or modify
|
7 | a8083063 | Iustin Pop | # it under the terms of the GNU General Public License as published by
|
8 | a8083063 | Iustin Pop | # the Free Software Foundation; either version 2 of the License, or
|
9 | a8083063 | Iustin Pop | # (at your option) any later version.
|
10 | a8083063 | Iustin Pop | #
|
11 | a8083063 | Iustin Pop | # This program is distributed in the hope that it will be useful, but
|
12 | a8083063 | Iustin Pop | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | a8083063 | Iustin Pop | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | a8083063 | Iustin Pop | # General Public License for more details.
|
15 | a8083063 | Iustin Pop | #
|
16 | a8083063 | Iustin Pop | # You should have received a copy of the GNU General Public License
|
17 | a8083063 | Iustin Pop | # along with this program; if not, write to the Free Software
|
18 | a8083063 | Iustin Pop | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
19 | a8083063 | Iustin Pop | # 02110-1301, USA.
|
20 | a8083063 | Iustin Pop | |
21 | a8083063 | Iustin Pop | |
22 | b8028dcf | Michael Hanselmann | """Ganeti exception handling.
|
23 | b8028dcf | Michael Hanselmann |
|
24 | b8028dcf | Michael Hanselmann | """
|
25 | b8028dcf | Michael Hanselmann | |
26 | b8028dcf | Michael Hanselmann | from ganeti import compat |
27 | a8083063 | Iustin Pop | |
28 | a8083063 | Iustin Pop | |
29 | 5c983ee5 | Iustin Pop | # OpPrereqError failure types
|
30 | 5c983ee5 | Iustin Pop | |
31 | 402ff455 | Michael Hanselmann | #: Resolver errors
|
32 | 104f4ca1 | Iustin Pop | ECODE_RESOLVER = "resolver_error"
|
33 | 402ff455 | Michael Hanselmann | |
34 | 402ff455 | Michael Hanselmann | #: Not enough resources (iallocator failure, disk space, memory, etc.)
|
35 | 5c983ee5 | Iustin Pop | ECODE_NORES = "insufficient_resources"
|
36 | 402ff455 | Michael Hanselmann | |
37 | 518a45e5 | Michael Hanselmann | #: Temporarily out of resources; operation can be tried again
|
38 | e2dd6ece | Michael Hanselmann | ECODE_TEMP_NORES = "temp_insufficient_resources"
|
39 | 518a45e5 | Michael Hanselmann | |
40 | 402ff455 | Michael Hanselmann | #: Wrong arguments (at syntax level)
|
41 | 5c983ee5 | Iustin Pop | ECODE_INVAL = "wrong_input"
|
42 | 402ff455 | Michael Hanselmann | |
43 | 402ff455 | Michael Hanselmann | #: Wrong entity state
|
44 | 5c983ee5 | Iustin Pop | ECODE_STATE = "wrong_state"
|
45 | 402ff455 | Michael Hanselmann | |
46 | 402ff455 | Michael Hanselmann | #: Entity not found
|
47 | 5c983ee5 | Iustin Pop | ECODE_NOENT = "unknown_entity"
|
48 | 402ff455 | Michael Hanselmann | |
49 | 402ff455 | Michael Hanselmann | #: Entity already exists
|
50 | 5c983ee5 | Iustin Pop | ECODE_EXISTS = "already_exists"
|
51 | 402ff455 | Michael Hanselmann | |
52 | 402ff455 | Michael Hanselmann | #: Resource not unique (e.g. MAC or IP duplication)
|
53 | 5c983ee5 | Iustin Pop | ECODE_NOTUNIQUE = "resource_not_unique"
|
54 | 402ff455 | Michael Hanselmann | |
55 | 402ff455 | Michael Hanselmann | #: Internal cluster error
|
56 | 5c983ee5 | Iustin Pop | ECODE_FAULT = "internal_error"
|
57 | 402ff455 | Michael Hanselmann | |
58 | 402ff455 | Michael Hanselmann | #: Environment error (e.g. node disk error)
|
59 | 5c983ee5 | Iustin Pop | ECODE_ENVIRON = "environment_error"
|
60 | 5c983ee5 | Iustin Pop | |
61 | df156277 | Michael Hanselmann | #: List of all failure types
|
62 | b8028dcf | Michael Hanselmann | ECODE_ALL = compat.UniqueFrozenset([ |
63 | df156277 | Michael Hanselmann | ECODE_RESOLVER, |
64 | df156277 | Michael Hanselmann | ECODE_NORES, |
65 | 518a45e5 | Michael Hanselmann | ECODE_TEMP_NORES, |
66 | df156277 | Michael Hanselmann | ECODE_INVAL, |
67 | df156277 | Michael Hanselmann | ECODE_STATE, |
68 | df156277 | Michael Hanselmann | ECODE_NOENT, |
69 | df156277 | Michael Hanselmann | ECODE_EXISTS, |
70 | df156277 | Michael Hanselmann | ECODE_NOTUNIQUE, |
71 | df156277 | Michael Hanselmann | ECODE_FAULT, |
72 | df156277 | Michael Hanselmann | ECODE_ENVIRON, |
73 | df156277 | Michael Hanselmann | ]) |
74 | df156277 | Michael Hanselmann | |
75 | 5c983ee5 | Iustin Pop | |
76 | a8083063 | Iustin Pop | class GenericError(Exception): |
77 | a8083063 | Iustin Pop | """Base exception for Ganeti.
|
78 | a8083063 | Iustin Pop |
|
79 | a8083063 | Iustin Pop | """
|
80 | a8083063 | Iustin Pop | |
81 | a8083063 | Iustin Pop | |
82 | a8083063 | Iustin Pop | class LockError(GenericError): |
83 | a8083063 | Iustin Pop | """Lock error exception.
|
84 | a8083063 | Iustin Pop |
|
85 | a8083063 | Iustin Pop | This signifies problems in the locking subsystem.
|
86 | a8083063 | Iustin Pop |
|
87 | a8083063 | Iustin Pop | """
|
88 | a8083063 | Iustin Pop | |
89 | a8083063 | Iustin Pop | |
90 | b6522276 | Michael Hanselmann | class PidFileLockError(LockError): |
91 | b6522276 | Michael Hanselmann | """PID file is already locked by another process.
|
92 | b6522276 | Michael Hanselmann |
|
93 | b6522276 | Michael Hanselmann | """
|
94 | b6522276 | Michael Hanselmann | |
95 | b6522276 | Michael Hanselmann | |
96 | a8083063 | Iustin Pop | class HypervisorError(GenericError): |
97 | a8083063 | Iustin Pop | """Hypervisor-related exception.
|
98 | a8083063 | Iustin Pop |
|
99 | a8083063 | Iustin Pop | This is raised in case we can't communicate with the hypervisor
|
100 | a8083063 | Iustin Pop | properly.
|
101 | a8083063 | Iustin Pop |
|
102 | a8083063 | Iustin Pop | """
|
103 | a8083063 | Iustin Pop | |
104 | a8083063 | Iustin Pop | |
105 | 58502c9e | Dimitris Aragiorgis | class HotplugError(HypervisorError): |
106 | 58502c9e | Dimitris Aragiorgis | """Hotplug-related exception.
|
107 | 58502c9e | Dimitris Aragiorgis |
|
108 | 58502c9e | Dimitris Aragiorgis | This is raised in case a hotplug action fails or is not supported.
|
109 | 58502c9e | Dimitris Aragiorgis | It is currently used only by KVM hypervisor.
|
110 | 58502c9e | Dimitris Aragiorgis |
|
111 | 58502c9e | Dimitris Aragiorgis | """
|
112 | 58502c9e | Dimitris Aragiorgis | |
113 | 58502c9e | Dimitris Aragiorgis | |
114 | a8083063 | Iustin Pop | class ProgrammerError(GenericError): |
115 | a8083063 | Iustin Pop | """Programming-related error.
|
116 | a8083063 | Iustin Pop |
|
117 | a8083063 | Iustin Pop | This is raised in cases we determine that the calling conventions
|
118 | a8083063 | Iustin Pop | have been violated, meaning we got some desynchronisation between
|
119 | a8083063 | Iustin Pop | parts of our code. It signifies a real programming bug.
|
120 | a8083063 | Iustin Pop |
|
121 | a8083063 | Iustin Pop | """
|
122 | a8083063 | Iustin Pop | |
123 | a8083063 | Iustin Pop | |
124 | a8083063 | Iustin Pop | class BlockDeviceError(GenericError): |
125 | a8083063 | Iustin Pop | """Block-device related exception.
|
126 | a8083063 | Iustin Pop |
|
127 | a8083063 | Iustin Pop | This is raised in case we can't setup the instance's block devices
|
128 | a8083063 | Iustin Pop | properly.
|
129 | a8083063 | Iustin Pop |
|
130 | a8083063 | Iustin Pop | """
|
131 | a8083063 | Iustin Pop | |
132 | a8083063 | Iustin Pop | |
133 | a8083063 | Iustin Pop | class ConfigurationError(GenericError): |
134 | a8083063 | Iustin Pop | """Configuration related exception.
|
135 | a8083063 | Iustin Pop |
|
136 | a8083063 | Iustin Pop | Things like having an instance with a primary node that doesn't
|
137 | a8083063 | Iustin Pop | exist in the config or such raise this exception.
|
138 | a8083063 | Iustin Pop |
|
139 | a8083063 | Iustin Pop | """
|
140 | a8083063 | Iustin Pop | |
141 | a8083063 | Iustin Pop | |
142 | 4b63dc7a | Iustin Pop | class ConfigVersionMismatch(ConfigurationError): |
143 | 4b63dc7a | Iustin Pop | """Version mismatch in the configuration file.
|
144 | 4b63dc7a | Iustin Pop |
|
145 | 4b63dc7a | Iustin Pop | The error has two arguments: the expected and the actual found
|
146 | 4b63dc7a | Iustin Pop | version.
|
147 | 4b63dc7a | Iustin Pop |
|
148 | 4b63dc7a | Iustin Pop | """
|
149 | 4b63dc7a | Iustin Pop | |
150 | 4b63dc7a | Iustin Pop | |
151 | 1de1cf25 | Apollon Oikonomopoulos | class AddressPoolError(GenericError): |
152 | 1de1cf25 | Apollon Oikonomopoulos | """Errors related to IP address pools.
|
153 | 1de1cf25 | Apollon Oikonomopoulos |
|
154 | 1de1cf25 | Apollon Oikonomopoulos | """
|
155 | 1de1cf25 | Apollon Oikonomopoulos | |
156 | 1de1cf25 | Apollon Oikonomopoulos | |
157 | 2c8a5690 | Guido Trotter | class ReservationError(GenericError): |
158 | 2c8a5690 | Guido Trotter | """Errors reserving a resource.
|
159 | 2c8a5690 | Guido Trotter |
|
160 | 2c8a5690 | Guido Trotter | """
|
161 | 2c8a5690 | Guido Trotter | |
162 | 2c8a5690 | Guido Trotter | |
163 | a8083063 | Iustin Pop | class RemoteError(GenericError): |
164 | a8083063 | Iustin Pop | """Programming-related error on remote call.
|
165 | a8083063 | Iustin Pop |
|
166 | a8083063 | Iustin Pop | This is raised when an unhandled error occurs in a call to a
|
167 | a8083063 | Iustin Pop | remote node. It usually signifies a real programming bug.
|
168 | a8083063 | Iustin Pop |
|
169 | a8083063 | Iustin Pop | """
|
170 | a8083063 | Iustin Pop | |
171 | a8083063 | Iustin Pop | |
172 | f4a2f532 | Guido Trotter | class SignatureError(GenericError): |
173 | f4a2f532 | Guido Trotter | """Error authenticating a remote message.
|
174 | f4a2f532 | Guido Trotter |
|
175 | f4a2f532 | Guido Trotter | This is raised when the hmac signature on a message doesn't verify correctly
|
176 | f4a2f532 | Guido Trotter | to the message itself. It can happen because of network unreliability or
|
177 | f4a2f532 | Guido Trotter | because of spurious traffic.
|
178 | f4a2f532 | Guido Trotter |
|
179 | f4a2f532 | Guido Trotter | """
|
180 | f4a2f532 | Guido Trotter | |
181 | f4a2f532 | Guido Trotter | |
182 | a8083063 | Iustin Pop | class ParameterError(GenericError): |
183 | a8083063 | Iustin Pop | """A passed parameter to a command is invalid.
|
184 | a8083063 | Iustin Pop |
|
185 | a8083063 | Iustin Pop | This is raised when the parameter passed to a request function is
|
186 | a8083063 | Iustin Pop | invalid. Correct code should have verified this before passing the
|
187 | a8083063 | Iustin Pop | request structure.
|
188 | a8083063 | Iustin Pop |
|
189 | a8083063 | Iustin Pop | The argument to this exception should be the parameter name.
|
190 | a8083063 | Iustin Pop |
|
191 | a8083063 | Iustin Pop | """
|
192 | a8083063 | Iustin Pop | |
193 | a8083063 | Iustin Pop | |
194 | 776b6291 | René Nussbaumer | class ResultValidationError(GenericError): |
195 | 776b6291 | René Nussbaumer | """The iallocation results fails validation.
|
196 | 776b6291 | René Nussbaumer |
|
197 | 776b6291 | René Nussbaumer | """
|
198 | 776b6291 | René Nussbaumer | |
199 | 776b6291 | René Nussbaumer | |
200 | a8083063 | Iustin Pop | class OpPrereqError(GenericError): |
201 | a8083063 | Iustin Pop | """Prerequisites for the OpCode are not fulfilled.
|
202 | a8083063 | Iustin Pop |
|
203 | 86a24969 | Dato Simó | This exception has two arguments: an error message, and one of the
|
204 | 5c983ee5 | Iustin Pop | ECODE_* codes.
|
205 | 5c983ee5 | Iustin Pop |
|
206 | a8083063 | Iustin Pop | """
|
207 | a8083063 | Iustin Pop | |
208 | 098c0958 | Michael Hanselmann | |
209 | a8083063 | Iustin Pop | class OpExecError(GenericError): |
210 | a8083063 | Iustin Pop | """Error during OpCode execution.
|
211 | a8083063 | Iustin Pop |
|
212 | a8083063 | Iustin Pop | """
|
213 | a8083063 | Iustin Pop | |
214 | 098c0958 | Michael Hanselmann | |
215 | 1ce03fb1 | Michael Hanselmann | class OpResultError(GenericError): |
216 | 1ce03fb1 | Michael Hanselmann | """Issue with OpCode result.
|
217 | 1ce03fb1 | Michael Hanselmann |
|
218 | 1ce03fb1 | Michael Hanselmann | """
|
219 | 1ce03fb1 | Michael Hanselmann | |
220 | 1ce03fb1 | Michael Hanselmann | |
221 | 9b221ea4 | Michele Tartara | class DeviceCreationError(GenericError): |
222 | 9b221ea4 | Michele Tartara | """Error during the creation of a device.
|
223 | 9b221ea4 | Michele Tartara |
|
224 | 9b221ea4 | Michele Tartara | This exception should contain the list of the devices actually created
|
225 | 9b221ea4 | Michele Tartara | up to now, in the form of pairs (node, device)
|
226 | 9b221ea4 | Michele Tartara |
|
227 | 9b221ea4 | Michele Tartara | """
|
228 | 9b221ea4 | Michele Tartara | def __init__(self, message, created_devices): |
229 | 9b221ea4 | Michele Tartara | GenericError.__init__(self)
|
230 | 9b221ea4 | Michele Tartara | self.message = message
|
231 | 9b221ea4 | Michele Tartara | self.created_devices = created_devices
|
232 | 9b221ea4 | Michele Tartara | |
233 | 9b221ea4 | Michele Tartara | def __str__(self): |
234 | 9b221ea4 | Michele Tartara | return self.message |
235 | 9b221ea4 | Michele Tartara | |
236 | 9b221ea4 | Michele Tartara | |
237 | a8083063 | Iustin Pop | class OpCodeUnknown(GenericError): |
238 | a8083063 | Iustin Pop | """Unknown opcode submitted.
|
239 | a8083063 | Iustin Pop |
|
240 | a8083063 | Iustin Pop | This signifies a mismatch between the definitions on the client and
|
241 | a8083063 | Iustin Pop | server side.
|
242 | a8083063 | Iustin Pop |
|
243 | a8083063 | Iustin Pop | """
|
244 | a8083063 | Iustin Pop | |
245 | 098c0958 | Michael Hanselmann | |
246 | 685ee993 | Iustin Pop | class JobLost(GenericError): |
247 | 685ee993 | Iustin Pop | """Submitted job lost.
|
248 | 685ee993 | Iustin Pop |
|
249 | 685ee993 | Iustin Pop | The job was submitted but it cannot be found in the current job
|
250 | 685ee993 | Iustin Pop | list.
|
251 | 685ee993 | Iustin Pop |
|
252 | 685ee993 | Iustin Pop | """
|
253 | 685ee993 | Iustin Pop | |
254 | 685ee993 | Iustin Pop | |
255 | 3d6c5566 | Guido Trotter | class JobFileCorrupted(GenericError): |
256 | 3d6c5566 | Guido Trotter | """Job file could not be properly decoded/restored.
|
257 | 3d6c5566 | Guido Trotter |
|
258 | 3d6c5566 | Guido Trotter | """
|
259 | 3d6c5566 | Guido Trotter | |
260 | 3d6c5566 | Guido Trotter | |
261 | 89e1fc26 | Iustin Pop | class ResolverError(GenericError): |
262 | 89e1fc26 | Iustin Pop | """Host name cannot be resolved.
|
263 | 89e1fc26 | Iustin Pop |
|
264 | 89e1fc26 | Iustin Pop | This is not a normal situation for Ganeti, as we rely on having a
|
265 | 89e1fc26 | Iustin Pop | working resolver.
|
266 | 89e1fc26 | Iustin Pop |
|
267 | 89e1fc26 | Iustin Pop | The non-resolvable hostname is available as the first element of the
|
268 | 89e1fc26 | Iustin Pop | args tuple; the other two elements of the tuple are the first two
|
269 | 89e1fc26 | Iustin Pop | args of the socket.gaierror exception (error code and description).
|
270 | 89e1fc26 | Iustin Pop |
|
271 | 89e1fc26 | Iustin Pop | """
|
272 | 89e1fc26 | Iustin Pop | |
273 | 89e1fc26 | Iustin Pop | |
274 | a8083063 | Iustin Pop | class HooksFailure(GenericError): |
275 | a8083063 | Iustin Pop | """A generic hook failure.
|
276 | a8083063 | Iustin Pop |
|
277 | a8083063 | Iustin Pop | This signifies usually a setup misconfiguration.
|
278 | a8083063 | Iustin Pop |
|
279 | a8083063 | Iustin Pop | """
|
280 | a8083063 | Iustin Pop | |
281 | 098c0958 | Michael Hanselmann | |
282 | a8083063 | Iustin Pop | class HooksAbort(HooksFailure): |
283 | a8083063 | Iustin Pop | """A required hook has failed.
|
284 | a8083063 | Iustin Pop |
|
285 | a8083063 | Iustin Pop | This caused an abort of the operation in the initial phase. This
|
286 | a8083063 | Iustin Pop | exception always has an attribute args which is a list of tuples of:
|
287 | a8083063 | Iustin Pop | - node: the source node on which this hooks has failed
|
288 | a8083063 | Iustin Pop | - script: the name of the script which aborted the run
|
289 | a8083063 | Iustin Pop |
|
290 | a8083063 | Iustin Pop | """
|
291 | a8083063 | Iustin Pop | |
292 | 098c0958 | Michael Hanselmann | |
293 | a8083063 | Iustin Pop | class UnitParseError(GenericError): |
294 | a8083063 | Iustin Pop | """Unable to parse size unit.
|
295 | a8083063 | Iustin Pop |
|
296 | a8083063 | Iustin Pop | """
|
297 | a8083063 | Iustin Pop | |
298 | ac2d0fe4 | Michael Hanselmann | |
299 | 31155d60 | Balazs Lecz | class ParseError(GenericError): |
300 | 31155d60 | Balazs Lecz | """Generic parse error.
|
301 | 31155d60 | Balazs Lecz |
|
302 | 31155d60 | Balazs Lecz | Raised when unable to parse user input.
|
303 | 31155d60 | Balazs Lecz |
|
304 | 31155d60 | Balazs Lecz | """
|
305 | 31155d60 | Balazs Lecz | |
306 | 31155d60 | Balazs Lecz | |
307 | a5728081 | Guido Trotter | class TypeEnforcementError(GenericError): |
308 | a5728081 | Guido Trotter | """Unable to enforce data type.
|
309 | a5728081 | Guido Trotter |
|
310 | a5728081 | Guido Trotter | """
|
311 | a8083063 | Iustin Pop | |
312 | ac2d0fe4 | Michael Hanselmann | |
313 | b6267745 | Andrea Spadaccini | class X509CertError(GenericError): |
314 | b6267745 | Andrea Spadaccini | """Invalid X509 certificate.
|
315 | b6267745 | Andrea Spadaccini |
|
316 | b6267745 | Andrea Spadaccini | This error has two arguments: the certificate filename and the error cause.
|
317 | b6267745 | Andrea Spadaccini |
|
318 | b6267745 | Andrea Spadaccini | """
|
319 | b6267745 | Andrea Spadaccini | |
320 | b6267745 | Andrea Spadaccini | |
321 | 5c947f38 | Iustin Pop | class TagError(GenericError): |
322 | 5c947f38 | Iustin Pop | """Generic tag error.
|
323 | 5c947f38 | Iustin Pop |
|
324 | 5c947f38 | Iustin Pop | The argument to this exception will show the exact error.
|
325 | 5c947f38 | Iustin Pop |
|
326 | 5c947f38 | Iustin Pop | """
|
327 | 7bca53e4 | Michael Hanselmann | |
328 | 7bca53e4 | Michael Hanselmann | |
329 | 7bca53e4 | Michael Hanselmann | class CommandError(GenericError): |
330 | 7bca53e4 | Michael Hanselmann | """External command error.
|
331 | 7bca53e4 | Michael Hanselmann |
|
332 | 7bca53e4 | Michael Hanselmann | """
|
333 | e50bdd68 | Guido Trotter | |
334 | e50bdd68 | Guido Trotter | |
335 | ac2d0fe4 | Michael Hanselmann | class StorageError(GenericError): |
336 | ac2d0fe4 | Michael Hanselmann | """Storage-related exception.
|
337 | ac2d0fe4 | Michael Hanselmann |
|
338 | ac2d0fe4 | Michael Hanselmann | """
|
339 | ac2d0fe4 | Michael Hanselmann | |
340 | 589dee9a | Guido Trotter | |
341 | 589dee9a | Guido Trotter | class InotifyError(GenericError): |
342 | 589dee9a | Guido Trotter | """Error raised when there is a failure setting up an inotify watcher.
|
343 | 589dee9a | Guido Trotter |
|
344 | 589dee9a | Guido Trotter | """
|
345 | 589dee9a | Guido Trotter | |
346 | ac2d0fe4 | Michael Hanselmann | |
347 | e50bdd68 | Guido Trotter | class QuitGanetiException(Exception): |
348 | 7e975535 | Stephen Shirley | """Signal Ganeti that it must quit.
|
349 | e50bdd68 | Guido Trotter |
|
350 | 0623d351 | Iustin Pop | This is not necessarily an error (and thus not a subclass of
|
351 | 0623d351 | Iustin Pop | GenericError), but it's an exceptional circumstance and it is thus
|
352 | 300e5450 | Michael Hanselmann | treated. This exception should be instantiated with two values. The
|
353 | 0623d351 | Iustin Pop | first one will specify the return code to the caller, and the second
|
354 | 0623d351 | Iustin Pop | one will be the returned result (either as an error or as a normal
|
355 | 0623d351 | Iustin Pop | result). Usually only the leave cluster rpc call should return
|
356 | 0623d351 | Iustin Pop | status True (as there it's expected we quit), every other call will
|
357 | 0623d351 | Iustin Pop | return status False (as a critical error was encountered).
|
358 | e50bdd68 | Guido Trotter |
|
359 | c41eea6e | Iustin Pop | Examples::
|
360 | c41eea6e | Iustin Pop |
|
361 | e50bdd68 | Guido Trotter | # Return a result of "True" to the caller, but quit ganeti afterwards
|
362 | 0623d351 | Iustin Pop | raise QuitGanetiException(True, None)
|
363 | e50bdd68 | Guido Trotter | # Send an error to the caller, and quit ganeti
|
364 | 0623d351 | Iustin Pop | raise QuitGanetiException(False, "Fatal safety violation, shutting down")
|
365 | e50bdd68 | Guido Trotter |
|
366 | e50bdd68 | Guido Trotter | """
|
367 | e50bdd68 | Guido Trotter | |
368 | f1da30e6 | Michael Hanselmann | |
369 | d11bda8d | Iustin Pop | class JobQueueError(GenericError): |
370 | f1da30e6 | Michael Hanselmann | """Job queue error.
|
371 | f1da30e6 | Michael Hanselmann |
|
372 | f1da30e6 | Michael Hanselmann | """
|
373 | 6797ec29 | Iustin Pop | |
374 | 6797ec29 | Iustin Pop | |
375 | 686d7433 | Iustin Pop | class JobQueueDrainError(JobQueueError): |
376 | 686d7433 | Iustin Pop | """Job queue is marked for drain error.
|
377 | 686d7433 | Iustin Pop |
|
378 | 686d7433 | Iustin Pop | This is raised when a job submission attempt is made but the queue
|
379 | 686d7433 | Iustin Pop | is marked for drain.
|
380 | 686d7433 | Iustin Pop |
|
381 | 686d7433 | Iustin Pop | """
|
382 | 686d7433 | Iustin Pop | |
383 | 686d7433 | Iustin Pop | |
384 | f87b405e | Michael Hanselmann | class JobQueueFull(JobQueueError): |
385 | f87b405e | Michael Hanselmann | """Job queue full error.
|
386 | f87b405e | Michael Hanselmann |
|
387 | f87b405e | Michael Hanselmann | Raised when job queue size reached its hard limit.
|
388 | f87b405e | Michael Hanselmann |
|
389 | f87b405e | Michael Hanselmann | """
|
390 | f87b405e | Michael Hanselmann | |
391 | f87b405e | Michael Hanselmann | |
392 | 9748ab35 | Guido Trotter | class ConfdMagicError(GenericError): |
393 | 9748ab35 | Guido Trotter | """A magic fourcc error in Ganeti confd.
|
394 | 9748ab35 | Guido Trotter |
|
395 | 9748ab35 | Guido Trotter | Errors processing the fourcc in ganeti confd datagrams.
|
396 | 9748ab35 | Guido Trotter |
|
397 | 9748ab35 | Guido Trotter | """
|
398 | 9748ab35 | Guido Trotter | |
399 | 9748ab35 | Guido Trotter | |
400 | e4ccf6cd | Guido Trotter | class ConfdClientError(GenericError): |
401 | e4ccf6cd | Guido Trotter | """A magic fourcc error in Ganeti confd.
|
402 | e4ccf6cd | Guido Trotter |
|
403 | e4ccf6cd | Guido Trotter | Errors in the confd client library.
|
404 | e4ccf6cd | Guido Trotter |
|
405 | e4ccf6cd | Guido Trotter | """
|
406 | e4ccf6cd | Guido Trotter | |
407 | e4ccf6cd | Guido Trotter | |
408 | c8eded0b | Guido Trotter | class UdpDataSizeError(GenericError): |
409 | c8eded0b | Guido Trotter | """UDP payload too big.
|
410 | c8eded0b | Guido Trotter |
|
411 | c8eded0b | Guido Trotter | """
|
412 | c8eded0b | Guido Trotter | |
413 | c8eded0b | Guido Trotter | |
414 | 4c32a8bd | Luca Bigliardi | class NoCtypesError(GenericError): |
415 | 4c32a8bd | Luca Bigliardi | """python ctypes module is not found in the system.
|
416 | 4c32a8bd | Luca Bigliardi |
|
417 | 4c32a8bd | Luca Bigliardi | """
|
418 | 4c32a8bd | Luca Bigliardi | |
419 | 4c32a8bd | Luca Bigliardi | |
420 | 8b312c1d | Manuel Franceschini | class IPAddressError(GenericError): |
421 | 8b312c1d | Manuel Franceschini | """Generic IP address error.
|
422 | 8b312c1d | Manuel Franceschini |
|
423 | 8b312c1d | Manuel Franceschini | """
|
424 | 8b312c1d | Manuel Franceschini | |
425 | 8b312c1d | Manuel Franceschini | |
426 | 7a8bda3f | Michael Hanselmann | class LuxiError(GenericError): |
427 | 7a8bda3f | Michael Hanselmann | """LUXI error.
|
428 | 7a8bda3f | Michael Hanselmann |
|
429 | 7a8bda3f | Michael Hanselmann | """
|
430 | 7a8bda3f | Michael Hanselmann | |
431 | 7a8bda3f | Michael Hanselmann | |
432 | 7578ab0a | Michael Hanselmann | class QueryFilterParseError(ParseError): |
433 | 7578ab0a | Michael Hanselmann | """Error while parsing query filter.
|
434 | 7578ab0a | Michael Hanselmann |
|
435 | 300e5450 | Michael Hanselmann | This exception must be instantiated with two values. The first one is a
|
436 | 300e5450 | Michael Hanselmann | string with an error description, the second one is an instance of a subclass
|
437 | 300e5450 | Michael Hanselmann | of C{pyparsing.ParseBaseException} (used to display the exact error
|
438 | 300e5450 | Michael Hanselmann | location).
|
439 | 300e5450 | Michael Hanselmann |
|
440 | 7578ab0a | Michael Hanselmann | """
|
441 | 7578ab0a | Michael Hanselmann | def GetDetails(self): |
442 | 7578ab0a | Michael Hanselmann | """Returns a list of strings with details about the error.
|
443 | 7578ab0a | Michael Hanselmann |
|
444 | 7578ab0a | Michael Hanselmann | """
|
445 | 7578ab0a | Michael Hanselmann | try:
|
446 | 7578ab0a | Michael Hanselmann | (_, inner) = self.args
|
447 | 7578ab0a | Michael Hanselmann | except IndexError: |
448 | 7578ab0a | Michael Hanselmann | return None |
449 | 7578ab0a | Michael Hanselmann | |
450 | 7578ab0a | Michael Hanselmann | return [str(inner.line), |
451 | 7578ab0a | Michael Hanselmann | (" " * (inner.column - 1)) + "^", |
452 | 7578ab0a | Michael Hanselmann | str(inner)]
|
453 | 7578ab0a | Michael Hanselmann | |
454 | 7578ab0a | Michael Hanselmann | |
455 | 352e1a26 | Michael Hanselmann | class RapiTestResult(GenericError): |
456 | 352e1a26 | Michael Hanselmann | """Exception containing results from RAPI test utilities.
|
457 | 352e1a26 | Michael Hanselmann |
|
458 | 352e1a26 | Michael Hanselmann | """
|
459 | 352e1a26 | Michael Hanselmann | |
460 | 352e1a26 | Michael Hanselmann | |
461 | fbdac0d9 | Michael Hanselmann | class FileStoragePathError(GenericError): |
462 | fbdac0d9 | Michael Hanselmann | """Error from file storage path validation.
|
463 | fbdac0d9 | Michael Hanselmann |
|
464 | fbdac0d9 | Michael Hanselmann | """
|
465 | fbdac0d9 | Michael Hanselmann | |
466 | fbdac0d9 | Michael Hanselmann | |
467 | 6797ec29 | Iustin Pop | # errors should be added above
|
468 | 6797ec29 | Iustin Pop | |
469 | 6797ec29 | Iustin Pop | |
470 | 6797ec29 | Iustin Pop | def GetErrorClass(name): |
471 | 6797ec29 | Iustin Pop | """Return the class of an exception.
|
472 | 6797ec29 | Iustin Pop |
|
473 | 6797ec29 | Iustin Pop | Given the class name, return the class itself.
|
474 | 6797ec29 | Iustin Pop |
|
475 | 6797ec29 | Iustin Pop | @type name: str
|
476 | 6797ec29 | Iustin Pop | @param name: the exception name
|
477 | 6797ec29 | Iustin Pop | @rtype: class
|
478 | 6797ec29 | Iustin Pop | @return: the actual class, or None if not found
|
479 | 6797ec29 | Iustin Pop |
|
480 | 6797ec29 | Iustin Pop | """
|
481 | 6797ec29 | Iustin Pop | item = globals().get(name, None) |
482 | 6797ec29 | Iustin Pop | if item is not None: |
483 | 6797ec29 | Iustin Pop | if not (isinstance(item, type(Exception)) and |
484 | 6797ec29 | Iustin Pop | issubclass(item, GenericError)):
|
485 | 6797ec29 | Iustin Pop | item = None
|
486 | 6797ec29 | Iustin Pop | return item
|
487 | 6956e9cd | Iustin Pop | |
488 | 6956e9cd | Iustin Pop | |
489 | 6956e9cd | Iustin Pop | def EncodeException(err): |
490 | 6956e9cd | Iustin Pop | """Encodes an exception into a format that L{MaybeRaise} will recognise.
|
491 | 6956e9cd | Iustin Pop |
|
492 | 6956e9cd | Iustin Pop | The passed L{err} argument will be formatted as a tuple (exception
|
493 | 6956e9cd | Iustin Pop | name, arguments) that the MaybeRaise function will recognise.
|
494 | 6956e9cd | Iustin Pop |
|
495 | 6956e9cd | Iustin Pop | @type err: GenericError child
|
496 | 6956e9cd | Iustin Pop | @param err: usually a child of GenericError (but any exception
|
497 | 6956e9cd | Iustin Pop | will be accepted)
|
498 | 6956e9cd | Iustin Pop | @rtype: tuple
|
499 | 6956e9cd | Iustin Pop | @return: tuple of (exception name, exception arguments)
|
500 | 6956e9cd | Iustin Pop |
|
501 | 6956e9cd | Iustin Pop | """
|
502 | 6956e9cd | Iustin Pop | return (err.__class__.__name__, err.args)
|
503 | 6956e9cd | Iustin Pop | |
504 | 6956e9cd | Iustin Pop | |
505 | 84f790e6 | Michael Hanselmann | def GetEncodedError(result): |
506 | 84f790e6 | Michael Hanselmann | """If this looks like an encoded Ganeti exception, return it.
|
507 | 6956e9cd | Iustin Pop |
|
508 | 6956e9cd | Iustin Pop | This function tries to parse the passed argument and if it looks
|
509 | 84f790e6 | Michael Hanselmann | like an encoding done by EncodeException, it will return the class
|
510 | 84f790e6 | Michael Hanselmann | object and arguments.
|
511 | 6956e9cd | Iustin Pop |
|
512 | 6956e9cd | Iustin Pop | """
|
513 | 6956e9cd | Iustin Pop | tlt = (tuple, list) |
514 | 6956e9cd | Iustin Pop | if (isinstance(result, tlt) and len(result) == 2 and |
515 | 6956e9cd | Iustin Pop | isinstance(result[1], tlt)): |
516 | 6956e9cd | Iustin Pop | # custom ganeti errors
|
517 | 84f790e6 | Michael Hanselmann | errcls = GetErrorClass(result[0])
|
518 | 84f790e6 | Michael Hanselmann | if errcls:
|
519 | 84f790e6 | Michael Hanselmann | return (errcls, tuple(result[1])) |
520 | 84f790e6 | Michael Hanselmann | |
521 | 84f790e6 | Michael Hanselmann | return None |
522 | 84f790e6 | Michael Hanselmann | |
523 | 84f790e6 | Michael Hanselmann | |
524 | 84f790e6 | Michael Hanselmann | def MaybeRaise(result): |
525 | 84f790e6 | Michael Hanselmann | """If this looks like an encoded Ganeti exception, raise it.
|
526 | 84f790e6 | Michael Hanselmann |
|
527 | 84f790e6 | Michael Hanselmann | This function tries to parse the passed argument and if it looks
|
528 | 84f790e6 | Michael Hanselmann | like an encoding done by EncodeException, it will re-raise it.
|
529 | 84f790e6 | Michael Hanselmann |
|
530 | 84f790e6 | Michael Hanselmann | """
|
531 | 84f790e6 | Michael Hanselmann | error = GetEncodedError(result) |
532 | 84f790e6 | Michael Hanselmann | if error:
|
533 | 84f790e6 | Michael Hanselmann | (errcls, args) = error |
534 | 98dfcaff | Iustin Pop | # pylint: disable=W0142
|
535 | 98dfcaff | Iustin Pop | raise errcls(*args) |