1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
|
# Copyright 2012 Managed I.T.
#
# Author: Kiall Mac Innes <kiall@managedit.ie>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import six
class Base(Exception):
error_code = 500
error_type = None
error_message = None
errors = None
def __init__(self, *args, **kwargs):
self.errors = kwargs.pop('errors', None)
self.object = kwargs.pop('object', None)
super(Base, self).__init__(*args, **kwargs)
if len(args) > 0 and isinstance(args[0], six.string_types):
self.error_message = args[0]
class Backend(Exception):
pass
class RelationNotLoaded(Base):
error_code = 500
error_type = 'relation_not_loaded'
def __init__(self, *args, **kwargs):
self.relation = kwargs.pop('relation', None)
super(RelationNotLoaded, self).__init__(*args, **kwargs)
self.error_message = "%(relation)s is not loaded on %(object)s" % \
{"relation": self.relation, "object": self.object.obj_name()}
def __str__(self):
return self.error_message
class AdapterNotFound(Base):
error_code = 500
error_type = 'adapter_not_found'
class NSD4SlaveBackendError(Backend):
pass
class NotImplemented(Base, NotImplementedError):
pass
class XFRFailure(Base):
pass
class ConfigurationError(Base):
error_type = 'configuration_error'
class UnknownFailure(Base):
error_code = 500
error_type = 'unknown_failure'
class CommunicationFailure(Base):
error_code = 504
error_type = 'communication_failure'
class NeutronCommunicationFailure(CommunicationFailure):
"""
Raised in case one of the alleged Neutron endpoints fails.
"""
error_type = 'neutron_communication_failure'
class NoFiltersConfigured(ConfigurationError):
error_code = 500
error_type = 'no_filters_configured'
class NoServersConfigured(ConfigurationError):
error_code = 500
error_type = 'no_servers_configured'
class MultiplePoolsFound(ConfigurationError):
error_code = 500
error_type = 'multiple_pools_found'
class NoPoolTargetsConfigured(ConfigurationError):
error_code = 500
error_type = 'no_pool_targets_configured'
class OverQuota(Base):
error_code = 413
error_type = 'over_quota'
expected = True
class QuotaResourceUnknown(Base):
error_type = 'quota_resource_unknown'
class InvalidObject(Base):
error_code = 400
error_type = 'invalid_object'
expected = True
class BadRequest(Base):
error_code = 400
error_type = 'bad_request'
expected = True
class EmptyRequestBody(BadRequest):
error_type = 'empty_request_body'
expected = True
class InvalidUUID(BadRequest):
error_type = 'invalid_uuid'
class NetworkEndpointNotFound(BadRequest):
error_type = 'no_endpoint'
error_code = 403
class MarkerNotFound(BadRequest):
error_type = 'marker_not_found'
class ValueError(BadRequest):
error_type = 'value_error'
class InvalidMarker(BadRequest):
error_type = 'invalid_marker'
class InvalidSortDir(BadRequest):
error_type = 'invalid_sort_dir'
class InvalidLimit(BadRequest):
error_type = 'invalid_limit'
class InvalidSortKey(BadRequest):
error_type = 'invalid_sort_key'
class InvalidJson(BadRequest):
error_type = 'invalid_json'
class InvalidOperation(BadRequest):
error_code = 400
error_type = 'invalid_operation'
class UnsupportedAccept(BadRequest):
error_code = 406
error_type = 'unsupported_accept'
class UnsupportedContentType(BadRequest):
error_code = 415
error_type = 'unsupported_content_type'
class InvalidZoneName(Base):
error_code = 400
error_type = 'invalid_zone_name'
expected = True
class InvalidRecordSetName(Base):
error_code = 400
error_type = 'invalid_recordset_name'
expected = True
class InvalidRecordSetLocation(Base):
error_code = 400
error_type = 'invalid_recordset_location'
expected = True
class InvaildZoneTransfer(Base):
error_code = 400
error_type = 'invalid_zone_transfer_request'
class InvalidTTL(Base):
error_code = 400
error_type = 'invalid_ttl'
class ZoneHasSubZone(Base):
error_code = 400
error_type = 'zone_has_sub_zone'
class Forbidden(Base):
error_code = 403
error_type = 'forbidden'
expected = True
class IllegalChildZone(Forbidden):
error_type = 'illegal_child'
class IllegalParentZone(Forbidden):
error_type = 'illegal_parent'
class IncorrectZoneTransferKey(Forbidden):
error_type = 'invalid_key'
class Duplicate(Base):
expected = True
error_code = 409
error_type = 'duplicate'
class DuplicateServiceStatus(Duplicate):
error_type = 'duplicate_service_status'
class DuplicateQuota(Duplicate):
error_type = 'duplicate_quota'
class DuplicateServer(Duplicate):
error_type = 'duplicate_server'
class DuplicateTsigKey(Duplicate):
error_type = 'duplicate_tsigkey'
class DuplicateZone(Duplicate):
error_type = 'duplicate_zone'
class DuplicateTld(Duplicate):
error_type = 'duplicate_tld'
class DuplicateRecordSet(Duplicate):
error_type = 'duplicate_recordset'
class DuplicateRecord(Duplicate):
error_type = 'duplicate_record'
class DuplicateBlacklist(Duplicate):
error_type = 'duplicate_blacklist'
class DuplicatePoolManagerStatus(Duplicate):
error_type = 'duplication_pool_manager_status'
class DuplicatePool(Duplicate):
error_type = 'duplicate_pool'
class DuplicatePoolAttribute(Duplicate):
error_type = 'duplicate_pool_attribute'
class DuplicatePoolNsRecord(Duplicate):
error_type = 'duplicate_pool_ns_record'
class DuplicatePoolNameserver(Duplicate):
error_type = 'duplicate_pool_nameserver'
class DuplicatePoolTarget(Duplicate):
error_type = 'duplicate_pool_target'
class DuplicatePoolTargetOption(Duplicate):
error_type = 'duplicate_pool_target_option'
class DuplicatePoolTargetMaster(Duplicate):
error_type = 'duplicate_pool_target_master'
class DuplicatePoolAlsoNotify(Duplicate):
error_type = 'duplicate_pool_also_notify'
class DuplicateZoneImport(Duplicate):
error_type = 'duplicate_zone_import'
class DuplicateZoneExport(Duplicate):
error_type = 'duplicate_zone_export'
class MethodNotAllowed(Base):
expected = True
error_code = 405
error_type = 'method_not_allowed'
class DuplicateZoneTransferRequest(Duplicate):
error_type = 'duplicate_zone_transfer_request'
class DuplicateZoneTransferAccept(Duplicate):
error_type = 'duplicate_zone_transfer_accept'
class DuplicateZoneAttribute(Duplicate):
error_type = 'duplicate_zone_attribute'
class DuplicateZoneMaster(Duplicate):
error_type = 'duplicate_zone_attribute'
class NotFound(Base):
expected = True
error_code = 404
error_type = 'not_found'
class ServiceStatusNotFound(NotFound):
error_type = 'service_status_not_found'
class QuotaNotFound(NotFound):
error_type = 'quota_not_found'
class ServerNotFound(NotFound):
error_type = 'server_not_found'
class TsigKeyNotFound(NotFound):
error_type = 'tsigkey_not_found'
class BlacklistNotFound(NotFound):
error_type = 'blacklist_not_found'
class ZoneNotFound(NotFound):
error_type = 'zone_not_found'
class ZoneMasterNotFound(NotFound):
error_type = 'zone_master_not_found'
class ZoneAttributeNotFound(NotFound):
error_type = 'zone_attribute_not_found'
class TldNotFound(NotFound):
error_type = 'tld_not_found'
class RecordSetNotFound(NotFound):
error_type = 'recordset_not_found'
class RecordNotFound(NotFound):
error_type = 'record_not_found'
class ReportNotFound(NotFound):
error_type = 'report_not_found'
class PoolManagerStatusNotFound(NotFound):
error_type = 'pool_manager_status_not_found'
class PoolNotFound(NotFound):
error_type = 'pool_not_found'
class NoValidPoolFound(NotFound):
error_type = 'no_valid_pool_found'
class PoolAttributeNotFound(NotFound):
error_type = 'pool_attribute_not_found'
class PoolNsRecordNotFound(NotFound):
error_type = 'pool_ns_record_not_found'
class PoolNameserverNotFound(NotFound):
error_type = 'pool_nameserver_not_found'
class PoolTargetNotFound(NotFound):
error_type = 'pool_target_not_found'
class PoolTargetOptionNotFound(NotFound):
error_type = 'pool_target_option_not_found'
class PoolTargetMasterNotFound(NotFound):
error_type = 'pool_target_master_not_found'
class PoolAlsoNotifyNotFound(NotFound):
error_type = 'pool_also_notify_not_found'
class ZoneTransferRequestNotFound(NotFound):
error_type = 'zone_transfer_request_not_found'
class ZoneTransferAcceptNotFound(NotFound):
error_type = 'zone_transfer_accept_not_found'
class ZoneImportNotFound(NotFound):
error_type = 'zone_import_not_found'
class ZoneExportNotFound(NotFound):
error_type = 'zone_export_not_found'
class LastServerDeleteNotAllowed(BadRequest):
error_type = 'last_server_delete_not_allowed'
class ResourceNotFound(NotFound):
# TODO(kiall): Should this be extending NotFound??
pass
|