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