2 # GeniAPI XML-RPC faults
8 class GeniFault(xmlrpclib.Fault):
9 def __init__(self, faultCode, faultString, extra = None):
11 faultString += ": " + extra
12 xmlrpclib.Fault.__init__(self, faultCode, faultString)
14 class GeniInvalidAPIMethod(GeniFault):
15 def __init__(self, method, interface = None, extra = None):
16 faultString = "Invalid method " + method
18 faultString += " for interface " + interface
19 GeniFault.__init__(self, 100, faultString, extra)
21 class GeniInvalidArgumentCount(GeniFault):
22 def __init__(self, got, min, max = min, extra = None):
24 expected = "%d-%d" % (min, max)
27 faultString = "Expected %s arguments, got %d" % \
29 GeniFault.__init__(self, 101, faultString, extra)
31 class GeniInvalidArgument(GeniFault):
32 def __init__(self, extra = None, name = None):
34 faultString = "Invalid %s value" % name
36 faultString = "Invalid argument"
37 GeniFault.__init__(self, 102, faultString, extra)
39 class GeniAuthenticationFailure(GeniFault):
40 def __init__(self, extra = None):
41 faultString = "Failed to authenticate call"
42 GeniFault.__init__(self, 103, faultString, extra)
44 class GeniDBError(GeniFault):
45 def __init__(self, extra = None):
46 faultString = "Database error"
47 GeniFault.__init__(self, 106, faultString, extra)
49 class GeniPermissionDenied(GeniFault):
50 def __init__(self, extra = None):
51 faultString = "Permission denied"
52 GeniFault.__init__(self, 108, faultString, extra)
54 class GeniNotImplemented(GeniFault):
55 def __init__(self, extra = None):
56 faultString = "Not fully implemented"
57 GeniFault.__init__(self, 109, faultString, extra)
59 class GeniAPIError(GeniFault):
60 def __init__(self, extra = None):
61 faultString = "Internal API error"
62 GeniFault.__init__(self, 111, faultString, extra)
64 class MalformedHrnException(GeniFault):
65 def __init__(self, value, extra = None):
67 faultString = "Malformed HRN: %(value)s" % locals()
68 GeniFault.__init__(self, 102, faultString, extra)
70 return repr(self.value)
72 class TreeException(GeniFault):
73 def __init__(self, value, extra = None):
75 faultString = "Tree Exception: %(value)s, " % locals()
76 GeniFault.__init__(self, 111, faultString, extra)
78 return repr(self.value)
80 class NonexistingRecord(GeniFault):
81 def __init__(self, value, extra = None):
83 faultString = "Non exsiting record %(value)s, " % locals()
84 GeniFault.__init__(self, 111, faultString, extra)
86 return repr(self.value)
88 class ExistingRecord(GeniFault):
89 def __init__(self, value, extra = None):
91 faultString = "Existing record: %(value)s, " % locals()
92 GeniFault.__init__(self, 111, faultString, extra)
94 return repr(self.value)
96 class NonexistingCredType(GeniFault):
97 def __init__(self, value, extra = None):
99 faultString = "Non existing record: %(value)s, " % locals()
100 GeniFault.__init__(self, 111, faultString, extra)
102 return repr(self.value)
104 class NonexistingFile(GeniFault):
105 def __init__(self, value):
107 faultString = "Non existing file: %(value)s, " % locals()
108 GeniFault.__init__(self, 111, faultString, extra)
110 return repr(self.value)
112 class InvalidRPCParams(GeniFault):
113 def __init__(self, value):
115 faultString = "Invalid RPC Params: %(value)s, " % locals()
116 GeniFault.__init__(self, 102, faultString, extra)
118 return repr(self.value)
120 # SMBAKER exceptions follow
122 class ConnectionKeyGIDMismatch(GeniFault):
123 def __init__(self, value, extra = None):
125 faultString = "Connection Key GID mismatch: %(value)s" % locals()
126 GeniFault.__init__(self, 102, faultstring, extra)
128 return repr(self.value)
130 class MissingCallerGID(GeniFault):
131 def __init__(self, value, extra = None):
133 faultString = "Missing Caller GID: %(value)s" % locals()
134 GeniFault.__init__(self, 102, faultstring, extra)
136 return repr(self.value)
138 class RecordNotFound(GeniFault):
139 def __init__(self, value, extra = None):
141 faultString = "Record not found: %(value)s" % locals()
142 GeniFault.__init__(self, 102, faultString, extra)
144 # return repr(self.value)
146 class UnknownGeniType(GeniFault):
147 def __init__(self, value, extra = None):
149 faultString = "Unknown Geni Type: %(value)s" % locals()
150 GeniFault.__init__(self, 102, faultString, extra)
152 return repr(self.value)
154 class MissingAuthority(GeniFault):
155 def __init__(self, value, extra = None):
157 faultString = "Missing authority: %(value)s" % locals()
158 GeniFault.__init__(self, 102, faultString, extra)
160 return repr(self.value)
162 class PlanetLabRecordDoesNotExist(GeniFault):
163 def __init__(self, value, extra = None):
165 faultString = "PlanetLab record does not exist : %(value)s" % locals()
166 GeniFault.__init__(self, 102, faultString, extra)
168 return repr(self.value)
170 class PermissionError(GeniFault):
171 def __init__(self, value, extra = None):
173 faultString = "Permission error: %(value)s" % locals()
174 GeniFault.__init__(self, 108, faultString, extra)
176 return repr(self.value)
178 class InsufficientRights(GeniFault):
179 def __init__(self, value, extra = None):
181 faultString = "Insufficient rights: %(value)s" % locals()
182 GeniFault.__init__(self, 108, faultString, extra)
184 return repr(self.value)
186 class MissingDelegateBit(GeniFault):
187 def __init__(self, value, extra = None):
189 faultString = "Missing delegate bit: %(value)s" % locals()
190 GeniFault.__init__(self, 108, faultString, extra)
192 return repr(self.value)
194 class ChildRightsNotSubsetOfParent(GeniFault):
195 def __init__(self, value, extra = None):
197 faultString = "Child rights not subset of parent: %(value)s" % locals()
198 GeniFault.__init__(self, 103, faultString, extra)
200 return repr(self.value)
202 class CertMissingParent(GeniFault):
203 def __init__(self, value, extra = None):
205 faultString = "Cert missing parent: %(value)s" % locals()
206 GeniFault.__init__(self, 103, faultString, extra)
208 return repr(self.value)
210 class CertNotSignedByParent(GeniFault):
211 def __init__(self, value, extra = None):
213 faultString = "Cert not signed by parent: %(value)s" % locals()
214 GeniFault.__init__(self, 103, faultString, extra)
216 return repr(self.value)
218 class GidInvalidParentHrn(GeniFault):
219 def __init__(self, value, extra = None):
221 faultString = "GID invalid parent hrn: %(value)s" % locals()
222 GeniFault.__init__(self, 102, faultString, extra)
224 return repr(self.value)
226 class SliverDoesNotExist(GeniFault):
227 def __init__(self, value, extra = None):
229 faultString = "Sliver does not exist : %(value)s" % locals()
230 GeniFault.__init__(self, 102, faultString, extra)
232 return repr(self.value)