Changeset e40c7ee
- Timestamp:
- Sep 10, 2008 1:17:43 PM (16 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
- Children:
- 89d9502
- Parents:
- 03e0290
- Location:
- fedd
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/fedd_allocate_project.py
r03e0290 re40c7ee 88 88 uid = proj['userID'] 89 89 # XXX: fedid 90 uname = uid.get(' username', None) or \90 uname = uid.get('localname', None) or \ 91 91 uid.get('kerberosUsername', None) or \ 92 92 uid.get('uri', None) … … 175 175 rv = {\ 176 176 'project': {\ 177 'name': { ' username': name },177 'name': { 'localname': name }, 178 178 'user' : [ {\ 179 'userID': { ' username' : uname },179 'userID': { 'localname' : uname }, 180 180 'access': [ { 'sshPubkey' : ssh } ], 181 181 } ]\ -
fedd/fedd_client.py
r03e0290 re40c7ee 99 99 fedd_client_opts.__init__(self) 100 100 self.add_option("-e", "--experiment_cert", dest="out_certfile", 101 type="string", help="output certificate file") 102 self.add_option("-E", "--experiment_name", dest="exp_name", 101 103 type="string", help="output certificate file") 102 104 self.add_option("-F","--useFedid", action="store_true", … … 141 143 help="Testbed identifier (URI) to contact (required)") 142 144 143 def exit_with_fault(dict, out=sys.stderr):144 """ Print an error message and exit.145 146 The dictionary contains the FeddFaultBody elements."""147 codestr = ""148 149 if dict.has_key('errstr'):150 codestr = "Error: %s" % dict['errstr']151 152 if dict.has_key('code'):153 if len(codestr) > 0 :154 codestr += " (%d)" % dict['code']155 else:156 codestr = "Error Code: %d" % dict['code']157 158 print>>out, codestr159 print>>out, "Description: %s" % dict['desc']160 sys.exit(dict.get('code', 20))161 162 145 class fedd_exp_data_opts(fedd_client_opts): 163 146 def __init__(self): … … 165 148 self.add_option("-e", "--experiment_cert", dest="exp_certfile", 166 149 type="string", help="output certificate file") 167 150 self.add_option("-E", "--experiment_name", dest="exp_name", 151 type="string", help="output certificate file") 152 153 def exit_with_fault(dict, out=sys.stderr): 154 """ Print an error message and exit. 155 156 The dictionary contains the FeddFaultBody elements.""" 157 codestr = "" 158 159 if dict.has_key('errstr'): 160 codestr = "Error: %s" % dict['errstr'] 161 162 if dict.has_key('code'): 163 if len(codestr) > 0 : 164 codestr += " (%d)" % dict['code'] 165 else: 166 codestr = "Error Code: %d" % dict['code'] 167 168 print>>out, codestr 169 print>>out, "Description: %s" % dict['desc'] 170 sys.exit(dict.get('code', 20)) 168 171 # Base class that will do a the SOAP/XMLRPC exchange for a request. 169 172 class fedd_rpc: … … 171 174 def __init__(self, fb): 172 175 self.desc = fb.get('desc', None) 173 self.code = fb.get('code', None)176 self.code = fb.get('code', -1) 174 177 self.errstr = fb.get('errstr', None) 175 178 … … 310 313 method_call = getattr(port, self.method, None) 311 314 resp = method_call( 312 encapsulate_binaries({ self.RequestBody: msg},\315 encapsulate_binaries({ self.RequestBody: req_dict},\ 313 316 ('fedid',))) 314 317 except Error, e: … … 317 320 if resp: 318 321 if resp.has_key(self.ResponseBody): 319 return resp[self.ResponseBody] 322 return decapsulate_binaries(resp[self.ResponseBody], 323 ('fedid',)) 320 324 elif resp.has_key('FeddFaultBody'): 321 325 raise self.RPCException(resp['FeddFaultBody']) … … 387 391 sys.exit("Cannot read certificate (%s)" % cert) 388 392 393 if opts.exp_name and opts.exp_certfile: 394 sys.exit("Only one of --experiment_cert and " +\ 395 "--experiment_name permitted"); 396 389 397 if opts.exp_certfile: 390 exp_fedid = fedid(file=opts.exp_certfile) 391 else: 392 sys.exit("Experiment certfile required") 398 exp_id = { 'fedid': fedid(file=opts.exp_certfile) } 399 400 if opts.exp_name: 401 exp_id = { 'localname' : opts.exp_name } 402 403 req = { 'experiment': exp_id } 393 404 394 405 try: 395 resp_dict = self.do_rpc( { 'experiment': { 'fedid': exp_fedid } },406 resp_dict = self.do_rpc(req, 396 407 opts.url, opts.transport, cert, opts.trusted, 397 408 serialize_only=opts.serialize_only, … … 401 412 {'desc': e.desc, 'errstr': e.errstr, 'code': e.code}) 402 413 except RuntimeError, e: 403 sys.exit("Error processing RPC: %s" % e.message) 414 print e 415 sys.exit("Error processing RPC: %s" % e) 404 416 405 417 try: … … 469 481 } ] 470 482 } 483 484 if opts.exp_name: 485 msg['experimentID'] = { 'localname': opts.exp_name } 471 486 472 487 if opts.debug > 1: print >>sys.stderr, msg … … 493 508 except IOError: 494 509 sys.exit('Could not write to %s' % out_certfile) 510 eid = resp_dict.get('experimentID', None) 511 if eid: 512 for id in eid: 513 for k in id.keys(): 514 if k == 'fedid': print "%s: %s" % (k,fedid(bits=id[k])) 515 else: print "%s: %s" % (k, id[k]) 495 516 496 517 class access(fedd_rpc): -
fedd/fedd_create_experiment.py
r03e0290 re40c7ee 624 624 'destinationTestbed' : { 'uri' : uri }, 625 625 'user': user, 626 'allocID' : { ' username': 'test' },626 'allocID' : { 'localname': 'test' }, 627 627 'access' : [ { 'sshPubkey' : self.ssh_pubkey } ] 628 628 } … … 1077 1077 pid = "dummy" 1078 1078 gid = "dummy" 1079 eid = self.exp_stem1080 if self.randomize_experiments:1081 for i in range(0,5):1082 eid += random.choice(string.ascii_letters)1083 1079 # XXX 1084 1080 fail_soft = False … … 1106 1102 else: 1107 1103 raise service_error(service_error.req, "No experiment description") 1104 1105 if req.has_key('experimentID') and \ 1106 req['experimentID'].has_key('localname'): 1107 eid = req['experimentID']['localname'] 1108 while (self.state.has_key(eid)): 1109 eid += random.choice(string.ascii_letters) 1110 else: 1111 eid = self.exp_stem 1112 for i in range(0,5): 1113 eid += random.choice(string.ascii_letters) 1114 while (self.state.has_key(eid)): 1115 eid = self.exp_stem 1116 for i in range(0,5): 1117 eid += random.choice(string.ascii_letters) 1108 1118 1109 1119 try: … … 1172 1182 "Failed to generate visualization") 1173 1183 1184 # save federant information 1185 for k in allocated.keys(): 1186 tbparams[k]['federant'] = {\ 1187 'name': [ { 'localname' : k} ],\ 1188 'emulab': tbparams[k]['emulab'],\ 1189 'master' : k == master,\ 1190 } 1191 1192 1174 1193 # Copy tarfiles and rpms needed at remote sites into a staging area 1175 1194 try: … … 1254 1273 os.rmdir(tmpdir) 1255 1274 1256 resp = { ' emulab' : [ tbparams[tb]['emulab'] \1275 resp = { 'federant' : [ tbparams[tb]['federant'] \ 1257 1276 for tb in tbparams.keys() \ 1258 if tbparams[tb].has_key(' emulab') ],\1277 if tbparams[tb].has_key('federant') ],\ 1259 1278 'experiment': vtopo,\ 1260 1279 'vis' : vis, 1261 'experimentID' : { 'fedid': expid },\ 1280 'experimentID' : [\ 1281 { 'fedid': expid }, { 'localname': eid },\ 1282 ],\ 1262 1283 'experimentAccess': { 'X509' : expcert },\ 1263 1284 } 1264 1285 1265 1286 self.state[expid] = {\ 1266 'emulab': [ tbparams[tb]['emulab'] \ 1287 'fedid': expid, 1288 'localname': eid, 1289 'federant': [ tbparams[tb]['federant'] \ 1267 1290 for tb in tbparams.keys() \ 1268 if tbparams[tb].has_key(' emulab') ],\1291 if tbparams[tb].has_key('federant') ],\ 1269 1292 'vis': vis,\ 1270 1293 'vtopo': vtopo,\ 1271 1294 } 1295 self.state[eid] = self.state[expid] 1272 1296 1273 1297 return resp … … 1279 1303 raise service_error(service_error.req, 1280 1304 "Bad request format (no VtopoRequestBody)") 1281 if req.has_key('experiment') and req['experiment'].has_key('fedid'): 1282 qfedid = req['experiment']['fedid'] 1305 exp = req.get('experiment', None) 1306 if exp: 1307 if exp.has_key('fedid'): 1308 key = fedid(bits=exp['fedid']) 1309 keytype = "fedid" 1310 elif exp.has_key('localname'): 1311 key = exp['localname'] 1312 keytype = "localname" 1313 else: 1314 raise service_error(service_error.req, "Unknown lookup type") 1283 1315 else: 1284 raise service_error(service_error.req, " Use fedid for lookup")1285 1286 if self.state.has_key( qfedid):1287 return { 'experiment' : { 'fedid': qfedid},\1288 'vtopo': self.state[ qfedid]['vtopo'],\1316 raise service_error(service_error.req, "No request?") 1317 1318 if self.state.has_key(key): 1319 return { 'experiment' : {keytype: key },\ 1320 'vtopo': self.state[key]['vtopo'],\ 1289 1321 } 1290 1322 else: … … 1297 1329 raise service_error(service_error.req, 1298 1330 "Bad request format (no VisRequestBody)") 1299 if req.has_key('experiment') and req['experiment'].has_key('fedid'): 1300 qfedid = req['experiment']['fedid'] 1331 exp = req.get('experiment', None) 1332 if exp: 1333 if exp.has_key('fedid'): 1334 key = fedid(bits=exp['fedid']) 1335 keytype = "fedid" 1336 elif exp.has_key('localname'): 1337 key = exp['localname'] 1338 keytype = "localname" 1339 else: 1340 raise service_error(service_error.req, "Unknown lookup type") 1301 1341 else: 1302 raise service_error(service_error.req, " Use fedid for lookup")1303 1304 if self.state.has_key( qfedid):1305 return { 'experiment' : { 'fedid': qfedid},\1306 'vis': self.state[ qfedid]['vis'],\1342 raise service_error(service_error.req, "No request?") 1343 1344 if self.state.has_key(key): 1345 return { 'experiment' : {keytype: key },\ 1346 'vis': self.state[key]['vis'],\ 1307 1347 } 1308 1348 else: … … 1366 1406 'experimentdescription' : content, 1367 1407 'master' : opts.master, 1368 'user': [ {'userID' : { ' username' : 'faber' } } ],1408 'user': [ {'userID' : { 'localname' : 'faber' } } ], 1369 1409 }, 1370 1410 None) -
fedd/fedd_proj.py
r03e0290 re40c7ee 502 502 # XXX ssh key additions 503 503 ap = { 'project': \ 504 { 'name' : { ' username' : found[0].name },\504 { 'name' : { 'localname' : found[0].name },\ 505 505 'user' : [ {\ 506 'userID': { ' username' : found[1] }, \506 'userID': { 'localname' : found[1] }, \ 507 507 'access': [ { 'sshPubkey': s } for s in ssh]}\ 508 508 ]\ … … 636 636 637 637 if msg != None: 638 return encapsulate_binaries({ "V toposResponseBody" : msg },638 return encapsulate_binaries({ "VisResponseBody" : msg }, 639 639 ('fedid',)) 640 640 else: -
fedd/fedd_types.xsd
r03e0290 re40c7ee 15 15 <xsd:element name="fedid" type="xsd:base64Binary"/> 16 16 <xsd:element name="uri" type="xsd:string"/> 17 <xsd:element name=" username" type="xsd:string"/>17 <xsd:element name="localname" type="xsd:string"/> 18 18 <xsd:element name="kerberosUsername" type="xsd:string"/> 19 19 </xsd:choice> … … 157 157 </xsd:sequence> 158 158 </xsd:complexType> 159 160 <xsd:complexType name="federatedExperimentType"> 161 <xsd:annotation> 162 <xsd:documentation> 163 The information about a federated sub-experiment 164 </xsd:documentation> 165 </xsd:annotation> 166 <xsd:sequence> 167 <xsd:element name="name" type="tns:IDType" minOccurs="1" 168 maxOccurs="unbounded"/> 169 <xsd:element name="emulab" type="tns:emulabType"/> 170 <xsd:element name="master" type="xsd:boolean"/> 171 </xsd:sequence> 172 </xsd:complexType> 173 159 174 160 175 <xsd:complexType name="vtoponodeType"> … … 304 319 <xsd:element name="experimentdescription" type="xsd:base64Binary"/> 305 320 <xsd:element name="master" type="xsd:string"/> 321 <xsd:element name="experimentID" type="tns:IDType" minOccurs="0" 322 maxOccurs="1"/> 306 323 </xsd:sequence> 307 324 </xsd:complexType> … … 314 331 </xsd:annotation> 315 332 <xsd:sequence> 316 <xsd:element name=" emulab" type="tns:emulabType" minOccurs="1"317 333 <xsd:element name="federant" type="tns:federatedExperimentType" 334 minOccurs="1" maxOccurs="unbounded"/> 318 335 <xsd:element name="experiment" type="tns:vtopoType" minOccurs="0" 319 336 maxOccurs="1"/> 320 337 <xsd:element name="vis" type="tns:visType" minOccurs="0" 321 338 maxOccurs="1"/> 322 <xsd:element name="experimentID" type="tns:IDType"/> 339 <xsd:element name="experimentID" type="tns:IDType" minOccurs="1" 340 maxOccurs="unbounded"/> 323 341 <xsd:element name="experimentAccess" type="tns:accessType" minOccurs="0" 324 342 maxOccurs="1"/> -
fedd/fedd_util.py
r03e0290 re40c7ee 169 169 if isinstance(id, type(fedid())): return { 'fedid': id } 170 170 elif id.startswith("http:") or id.startswith("https:"): return { 'uri': id } 171 else: return { ' username': id}171 else: return { 'localname': id} 172 172 173 173 def unpack_id(id): … … 175 175 if id.has_key("fedid"): return fedid(id["fedid"]) 176 176 else: 177 for k in (" username", "uri", "kerberosUsername"):177 for k in ("localname", "uri", "kerberosUsername"): 178 178 if id.has_key(k): return id[k] 179 179 return None
Note: See TracChangeset
for help on using the changeset viewer.