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