11 class SfaFault(xmlrpclib.Fault):
12 def __init__(self, faultCode, faultString, extra = None):
14 faultString += ": " + extra
15 xmlrpclib.Fault.__init__(self, faultCode, faultString)
17 class SfaInvalidAPIMethod(SfaFault):
18 def __init__(self, method, interface = None, extra = None):
19 faultString = "Invalid method " + method
21 faultString += " for interface " + interface
22 SfaFault.__init__(self, 100, faultString, extra)
24 class SfaInvalidArgumentCount(SfaFault):
25 def __init__(self, got, min, max = min, extra = None):
27 expected = "%d-%d" % (min, max)
30 faultString = "Expected %s arguments, got %d" % \
32 SfaFault.__init__(self, 101, faultString, extra)
34 class SfaInvalidArgument(SfaFault):
35 def __init__(self, extra = None, name = None):
37 faultString = "Invalid %s value" % name
39 faultString = "Invalid argument"
40 SfaFault.__init__(self, 102, faultString, extra)
42 class SfaAuthenticationFailure(SfaFault):
43 def __init__(self, extra = None):
44 faultString = "Failed to authenticate call"
45 SfaFault.__init__(self, 103, faultString, extra)
47 class SfaDBError(SfaFault):
48 def __init__(self, extra = None):
49 faultString = "Database error"
50 SfaFault.__init__(self, 106, faultString, extra)
52 class SfaPermissionDenied(SfaFault):
53 def __init__(self, extra = None):
54 faultString = "Permission denied"
55 SfaFault.__init__(self, 108, faultString, extra)
57 class SfaNotImplemented(SfaFault):
58 def __init__(self, extra = None):
59 faultString = "Not fully implemented"
60 SfaFault.__init__(self, 109, faultString, extra)
62 class SfaAPIError(SfaFault):
63 def __init__(self, extra = None):
64 faultString = "Internal API error"
65 SfaFault.__init__(self, 111, faultString, extra)
67 class MalformedHrnException(SfaFault):
68 def __init__(self, value, extra = None):
70 faultString = "Malformed HRN: %(value)s" % locals()
71 SfaFault.__init__(self, 102, faultString, extra)
73 return repr(self.value)
75 class TreeException(SfaFault):
76 def __init__(self, value, extra = None):
78 faultString = "Tree Exception: %(value)s, " % locals()
79 SfaFault.__init__(self, 111, faultString, extra)
81 return repr(self.value)
83 class NonexistingRecord(SfaFault):
84 def __init__(self, value, extra = None):
86 faultString = "Non exsiting record %(value)s, " % locals()
87 SfaFault.__init__(self, 111, faultString, extra)
89 return repr(self.value)
91 class ExistingRecord(SfaFault):
92 def __init__(self, value, extra = None):
94 faultString = "Existing record: %(value)s, " % locals()
95 SfaFault.__init__(self, 111, faultString, extra)
97 return repr(self.value)
99 class NonexistingCredType(SfaFault):
100 def __init__(self, value, extra = None):
102 faultString = "Non existing record: %(value)s, " % locals()
103 SfaFault.__init__(self, 111, faultString, extra)
105 return repr(self.value)
107 class NonexistingFile(SfaFault):
108 def __init__(self, value):
110 faultString = "Non existing file: %(value)s, " % locals()
111 SfaFault.__init__(self, 111, faultString, extra)
113 return repr(self.value)
115 class InvalidRPCParams(SfaFault):
116 def __init__(self, value):
118 faultString = "Invalid RPC Params: %(value)s, " % locals()
119 SfaFault.__init__(self, 102, faultString, extra)
121 return repr(self.value)
123 # SMBAKER exceptions follow
125 class ConnectionKeyGIDMismatch(SfaFault):
126 def __init__(self, value, extra = None):
128 faultString = "Connection Key GID mismatch: %(value)s" % locals()
129 SfaFault.__init__(self, 102, faultString, extra)
131 return repr(self.value)
133 class MissingCallerGID(SfaFault):
134 def __init__(self, value, extra = None):
136 faultString = "Missing Caller GID: %(value)s" % locals()
137 SfaFault.__init__(self, 102, faultString, extra)
139 return repr(self.value)
141 class RecordNotFound(SfaFault):
142 def __init__(self, value, extra = None):
144 faultString = "Record not found: %(value)s" % locals()
145 SfaFault.__init__(self, 102, faultString, extra)
147 # return repr(self.value)
149 class UnknownSfaType(SfaFault):
150 def __init__(self, value, extra = None):
152 faultString = "Unknown SFA Type: %(value)s" % locals()
153 SfaFault.__init__(self, 102, faultString, extra)
155 return repr(self.value)
157 class MissingAuthority(SfaFault):
158 def __init__(self, value, extra = None):
160 faultString = "Missing authority: %(value)s" % locals()
161 SfaFault.__init__(self, 102, faultString, extra)
163 return repr(self.value)
165 class PlanetLabRecordDoesNotExist(SfaFault):
166 def __init__(self, value, extra = None):
168 faultString = "PlanetLab record does not exist : %(value)s" % locals()
169 SfaFault.__init__(self, 102, faultString, extra)
171 return repr(self.value)
173 class PermissionError(SfaFault):
174 def __init__(self, value, extra = None):
176 faultString = "Permission error: %(value)s" % locals()
177 SfaFault.__init__(self, 108, faultString, extra)
179 return repr(self.value)
181 class InsufficientRights(SfaFault):
182 def __init__(self, value, extra = None):
184 faultString = "Insufficient rights: %(value)s" % locals()
185 SfaFault.__init__(self, 108, faultString, extra)
187 return repr(self.value)
189 class MissingDelegateBit(SfaFault):
190 def __init__(self, value, extra = None):
192 faultString = "Missing delegate bit: %(value)s" % locals()
193 SfaFault.__init__(self, 108, faultString, extra)
195 return repr(self.value)
197 class ChildRightsNotSubsetOfParent(SfaFault):
198 def __init__(self, value, extra = None):
200 faultString = "Child rights not subset of parent: %(value)s" % locals()
201 SfaFault.__init__(self, 103, faultString, extra)
203 return repr(self.value)
205 class CertMissingParent(SfaFault):
206 def __init__(self, value, extra = None):
208 faultString = "Cert missing parent: %(value)s" % locals()
209 SfaFault.__init__(self, 103, faultString, extra)
211 return repr(self.value)
213 class CertNotSignedByParent(SfaFault):
214 def __init__(self, value, extra = None):
216 faultString = "Cert not signed by parent: %(value)s" % locals()
217 SfaFault.__init__(self, 103, faultString, extra)
219 return repr(self.value)
221 class GidInvalidParentHrn(SfaFault):
222 def __init__(self, value, extra = None):
224 faultString = "GID invalid parent hrn: %(value)s" % locals()
225 SfaFault.__init__(self, 102, faultString, extra)
227 return repr(self.value)
229 class SliverDoesNotExist(SfaFault):
230 def __init__(self, value, extra = None):
232 faultString = "Sliver does not exist : %(value)s" % locals()
233 SfaFault.__init__(self, 102, faultString, extra)
235 return repr(self.value)
237 class BadRequestHash(xmlrpclib.Fault):
238 def __init__(self, hash = None):
239 faultString = "bad request hash: " + str(hash)
240 xmlrpclib.Fault.__init__(self, 902, faultString)
242 class MissingTrustedRoots(SfaFault):
243 def __init__(self, value, extra = None):
245 faultString = "Trusted root directory does not exist: %(value)s" % locals()
246 SfaFault.__init__(self, 102, faultString, extra)
248 return repr(self.value)
250 class MissingSfaInfo(SfaFault):
251 def __init__(self, value, extra = None):
253 faultString = "Missing information: %(value)s" % locals()
254 SfaFault.__init__(self, 102, faultString, extra)
256 return repr(self.value)