import repository from arizona
[raven.git] / apps / gacks / gacksexcep.py
1 import time
2
3 class GacksError(Exception):
4     def __init__(self, value):
5         self.value = value
6     def __str__(self):
7         return repr(self.value)
8
9 class GacksMultipleRecordCollision(GacksError):
10     pass
11
12 class GacksResourceNotFound(GacksError):
13     pass
14
15 class GacksConflictingInsert(GacksError):
16     pass
17
18 class GacksOutOfDateSequence(GacksError):
19     pass
20
21 class GacksCallerNotAllocator(GacksError):
22     pass
23
24 class GacksRequestSpansReservations(GacksError):
25     pass
26
27 class GacksBadRspecSyntax(GacksError):
28     pass
29
30 class GacksBadRequestHash(GacksError):
31     pass
32
33 class GacksMissingBindPrivilege(GacksError):
34     pass
35
36 class GacksBadUnits(GacksError):
37     pass
38
39 class GacksEmptyHandles(GacksError):
40     pass
41
42 class GacksPolicyViolation(GacksError):
43     pass
44
45 class GacksNoReserve(GacksError):
46     pass
47
48 class GacksEnforcerError(GacksError):
49     pass
50
51 class GacksNotAuthorized(GacksError):
52     pass
53
54 class GacksEnforcerDifferentTimes(GacksEnforcerError):
55     def __init__(self, firstHandle, secondHandle):
56         value = "Handle time mismatch (%d,%d) != (%d, %d)" % \
57             (firstHandle.timeStart, firstHandle.timeStop, secondHandle.timeStart, secondHandle.timeStop)
58         GacksEnforcerError.__init__(self, value)
59
60 class GacksEnforcerNoAccount(GacksEnforcerError):
61     def __init__(self, name):
62         GacksEnforcerError.__init__(self, "no account: " + name)
63
64 class GacksEnforcerNoResource(GacksEnforcerError):
65     def __init__(self, id):
66         GacksEnforcerError.__init__(self, "no resource: " + id)
67
68 class GacksEnforcerNoPolicy(GacksEnforcerError):
69     def __init__(self, level, id):
70         GacksEnforcerError.__init__(self, "no policy: " + level + " " + id)
71
72 class GacksEnforcerDurationTooLong(GacksEnforcerError):
73     def __init__(self, handle, maxDuration):
74         GacksEnforcerError.__init__(self, "duration too long: " + str(handle.get_duration()) + ">" + str(maxDuration))
75
76 class GacksEnforcerEndDateBeyondLimit(GacksEnforcerError):
77     def __init__(self, handle, maxTStop):
78         GacksEnforcerError.__init__(self, "end date beyond limit: " + str(handle.timeStop) + ">" + str(maxTStop))
79
80 class GacksEnforcerTooManyConcurrent(GacksEnforcerError):
81     def __init__(self, total):
82         GacksEnforcerError.__init__(self, "too many total units: " + str(total))
83
84 class GacksEnforcerTooManyOnNode(GacksEnforcerError):
85     def __init__(self, hostname, total):
86         GacksEnforcerError.__init__(self, "too many units on node: " + str(total) + " " + str(hostname))
87
88 class GacksEnforcerNoReservation(GacksEnforcerError):
89     def __init__(self, attempted, permitted):
90         GacksEnforcerError.__init__(self, "service only allows: " + ",".join(permitted))
91
92 class GacksEnforcerNotGoodStanding(GacksEnforcerError):
93     def __init__(self, name):
94         GacksEnforcerError.__init__(self, "account not in good standing: " + name)
95
96 class GacksEnforcerBucketUnderflow(GacksEnforcerError):
97     def __init__(self, t, total, limit):
98         GacksEnforcerError.__init__(self, "bucket underflow at " + time.ctime(t) + " tried to alloc " + str(total) + " from bucket of " + str(limit) )
99
100