1 # Inspired from GENI error codes
6 class ResultValue(dict):
34 SERVERBUSY : 'Server is (temporarily) too busy; try again later',
35 BADARGS : 'Bad Arguments: malformed',
36 ERROR : 'Error (other)',
37 FORBIDDEN : 'Operation Forbidden: eg supplied credentials do not provide sufficient privileges (on the given slice)',
38 BADVERSION : 'Bad Version (eg of RSpec)',
39 SERVERERROR : 'Server Error',
40 TOOBIG : 'Too Big (eg request RSpec)',
41 REFUSED : 'Operation Refused',
42 TIMEDOUT : 'Operation Timed Out',
43 DBERROR : 'Database Error',
47 ALLOWED_FIELDS = set(['origin', 'type', 'code', 'value', 'description', 'traceback', 'ts'])
49 def __init__(self, **kwargs):
52 given = set(kwargs.keys())
53 cstr_success = set(['code', 'origin', 'value']) <= given
54 cstr_error = set(['code', 'type', 'origin', 'description']) <= given
55 assert given <= self.ALLOWED_FIELDS, "Wrong fields in ResultValue constructor: %r" % (given - self.ALLOWED_FIELDS)
56 assert cstr_success or cstr_error, 'Incomplete set of fields in ResultValue constructor: %r' % given
58 dict.__init__(self, **kwargs)
60 # Set missing fields to None
61 for field in self.ALLOWED_FIELDS - given:
64 self['ts'] = time.time()
67 # Internal MySlice errors : return ERROR
68 # Internal MySlice warnings : return RESULT WITH WARNINGS
69 # Debug : add DEBUG INFORMATION
70 # Gateway errors : return RESULT WITH WARNING
71 # all Gateways errors : return ERROR
74 def get_result_value(self, results, result_value_array):
75 # let's analyze the results of the query plan
76 # XXX we should inspect all errors to determine whether to return a
78 if not result_value_array:
80 return ResultValue(code=self.SUCCESS, origin=[self.CORE, 0], value=results)
83 return ResultValue(code=self.WARNING, origin=[self.CORE, 0], description=result_value_array, value=results)
86 def get_error(self, error):
87 return ResultValue(code=error, origin=[self.CORE, 0], value=self.ERRSTR[error])
90 def get_success(self, result):
91 return ResultValue(code=self.SUCCESS, origin=[self.CORE, 0], value=result)
97 err = "%r" % self['description']
100 def to_html (raw_dict):
101 return pprint.pformat (raw_dict).replace("\\n","<br/>")
104 # 68 <value>9</value>
105 # 69 <label>DBERROR</label>
106 # 70 <description>Database Error</description>
109 # 73 <value>10</value>
110 # 74 <label>RPCERROR</label>
111 # 75 <description>RPC Error</description>
114 # 78 <value>11</value>
115 # 79 <label>UNAVAILABLE</label>
116 # 80 <description>Unavailable (eg server in lockdown)</description>
119 # 83 <value>12</value>
120 # 84 <label>SEARCHFAILED</label>
121 # 85 <description>Search Failed (eg for slice)</description>
124 # 88 <value>13</value>
125 # 89 <label>UNSUPPORTED</label>
126 # 90 <description>Operation Unsupported</description>
129 # 93 <value>14</value>
130 # 94 <label>BUSY</label>
131 # 95 <description>Busy (resource, slice, or server); try again
132 # later</description>
135 # 98 <value>15</value>
136 # 99 <label>EXPIRED</label>
137 # 100 <description>Expired (eg slice)</description>
140 # 103 <value>16</value>
141 # 104 <label>INPROGRESS</label>
142 # 105 <description>In Progress</description>
145 # 108 <value>17</value>
146 # 109 <label>ALREADYEXISTS</label>
147 # 110 <description>Already Exists (eg slice)</description>
149 # 112 <!-- 18+ not in original ProtoGENI implementation or Error Code --
150 # 113 -- proposal. -->
152 # 115 <value>18</value>
153 # 116 <label>MISSINGARGS</label>
154 # 117 <description>Required argument(s) missing</description>
157 # 120 <value>19</value>
158 # 121 <label>OUTOFRANGE</label>
159 # 122 <description>Input Argument outside of legal range</description>
162 # 125 <value>20</value>
163 # 126 <label>CREDENTIAL_INVALID</label>
164 # 127 <description>Not authorized: Supplied credential is
165 # invalid</description>
168 # 130 <value>21</value>
169 # 131 <label>CREDENTIAL_EXPIRED</label>
170 # 132 <description>Not authorized: Supplied credential expired</description>
173 # 135 <value>22</value>
174 # 136 <label>CREDENTIAL_MISMATCH</label>
175 # 137 <description>Not authorized: Supplied credential does not match client
176 # certificate or does not match the given slice URN</description>
179 # 140 <value>23</value>
180 # 141 <label>CREDENTIAL_SIGNER_UNTRUSTED</label>
181 # 142 <description>Not authorized: Supplied credential not signed by a trusted
182 # authority</description>
185 # 145 <value>24</value>
186 # 146 <label>VLAN_UNAVAILABLE</label>
187 # 147 <description>VLAN tag(s) requested not available (likely stitching
188 # failure)</description>
190 # 149 </geni-error-codes>
193 # || 0 || SUCCESS || "Success" ||
194 # || 1 || BADARGS || "Bad Arguments: malformed arguments" ||
195 # || 2 || ERROR || "Error (other)" ||
196 # || 3 || FORBIDDEN || "Operation Forbidden: eg supplied credentials do # not provide sufficient privileges (on given slice)" ||
197 # || 4 || BADVERSION || "Bad Version (eg of RSpec)" ||
198 # || 5 || SERVERERROR || "Server Error" ||
199 # || 6 || TOOBIG || "Too Big (eg request RSpec)" ||
200 # || 7 || REFUSED || "Operation Refused" ||
201 # || 8 || TIMEDOUT || "Operation Timed Out" ||
202 # || 9 || DBERROR || "Database Error" ||
203 # || 10 || RPCERROR || "RPC Error" ||
204 # || 11 || UNAVAILABLE || "Unavailable (eg server in lockdown)" ||
205 # || 12 || SEARCHFAILED || "Search Failed (eg for slice)" ||
206 # || 13 || UNSUPPORTED || "Operation Unsupported" ||
207 # || 14 || BUSY || "Busy (resource, slice, or server); try again # later" ||
208 # || 15 || EXPIRED || "Expired (eg slice)" ||
209 # || 16 || INPROGRESS || "In Progress" ||
210 # || 17 || ALREADYEXISTS || "Already Exists (eg the slice}" ||
211 # || 18 || MISSINGARGS || "Required argument(s) missing" ||
212 # || 19 || OUTOFRANGE || "Requested expiration time or other argument not # valid" ||
213 # || 20 || CREDENTIAL_INVALID || "Not authorized: Supplied credential is # invalid" ||
214 # || 21 || CREDENTIAL_EXPIRED || "Not authorized: Supplied credential # expired" ||
215 # || 22 || CREDENTIAL_MISMATCH || "Not authorized: Supplied credential # does not match the supplied client certificate or does not match the given slice # URN" ||
216 # || 23 || CREDENTIAL_SIGNER_UNTRUSTED || "Not authorized: Supplied # credential not signed by trusted authority" ||
217 # || 24 || VLAN_UNAVAILABLE || "VLAN tag(s) requested not available # (likely stitching failure)" ||
219 # 18+ not in original ProtoGENI implementation or Error Code proposal.
221 # Maping to SFA Faults:
222 # SfaAuthenticationFailure: FORBIDDEN
225 # SfaPermissionDenied: FORBIDDEN
226 # SfaNotImplemented: UNSUPPORTED
227 # SfaAPIError: SERVERERROR
228 # MalformedHrnException: BADARGS
229 # NonExistingRecord: SEARCHFAILED
230 # ExistingRecord: ALREADYEXISTS
231 # NonexistingCredType: SEARCHFAILED? FORBIDDEN? CREDENTIAL_INVALID?
232 # NonexitingFile: SEARCHFAILED
233 # InvalidRPCParams: RPCERROR
234 # ConnectionKeyGIDMismatch: FORBIDDEN? CREDENTIAL_MISMATCH?
235 # MissingCallerGID: SEARCHFAILED? CREDENTIAL_MISMATCH?
236 # RecordNotFound: SEARCHFAILED
237 # PlanetLAbRecordDoesNotExist: SEARCHFAILED
238 # PermissionError: FORBIDDEN
239 # InsufficientRights: FORBIDDEN
240 # MissingDelegateBit: CREDENTIAL_INVALID? FORBIDDEN?
241 # ChildRightsNotSubsetOfParent: CREDENTIAL_INVALID
242 # CertMissingParent: FORBIDDEN? CREDENTIAL_INVALID?
243 # CertNotSignedByParent: FORBIDDEN
244 # GidParentHrn: FORBIDDEN? CREDENTIAL_INVALID?
245 # GidInvalidParentHrn: FORBIDDEN? CREDENTIAL_INVALID?
246 # SliverDoesNotExist: SEARCHFAILED
247 # MissingTrustedRoots: SERVERERROR
248 # MissingSfaInfo: SERVERERROR
249 # InvalidRSpec: BADARGS
250 # InvalidRSpecElement: BADARGS
251 # AccountNotEnabled: REFUSED? FORBIDDEN?
252 # CredentialNotVerifiable: CREDENTIAL_INVALID
253 # CertExpired: EXPIRED? FORBIDDEN?