Changeset a3ad8bd
- Timestamp:
- Dec 4, 2009 2:21:11 PM (15 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
- Children:
- c17efe6
- Parents:
- 4ac0a41
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/fedd_client.py
r4ac0a41 ra3ad8bd 82 82 self.add_option("--trace", action="store_const", dest="tracefile", 83 83 const=sys.stderr, help="Print SOAP exchange to stderr") 84 class fedd_new_opts(fedd_client_opts): 85 def __init__(self): 86 fedd_client_opts.__init__(self) 87 self.add_option("-e", "--experiment_cert", dest="out_certfile", 88 type="string", help="output certificate file") 89 self.add_option("-E", "--experiment_name", dest="exp_name", 90 type="string", help="Suggested experiment name") 84 91 85 92 class fedd_create_opts(fedd_client_opts): … … 1314 1321 sys.exit("No log returned") 1315 1322 1316 class create(fedd_rpc):1323 class new(fedd_rpc): 1317 1324 def __init__(self): 1318 fedd_rpc.__init__(self, " Create")1325 fedd_rpc.__init__(self, "New") 1319 1326 def __call__(self): 1320 1327 access_keys = [] 1321 1328 # Process the options using the customized option parser defined above 1322 parser = fedd_create_opts(access_keys, self.add_ssh_key, 1323 self.add_x509_cert) 1329 parser = fedd_new_opts() 1324 1330 1325 1331 (opts, args) = parser.parse_args() … … 1329 1335 sys.exit("Cannot read trusted certificates (%s)" % opts.trusted) 1330 1336 1331 if not opts.project :1332 parser.error('--project is required')1333 1334 1337 if opts.debug > 0: opts.tracefile=sys.stderr 1335 1338 1336 1339 (user, cert) = self.get_user_info(access_keys) 1337 1338 if opts.user: user = opts.user1339 1340 1340 1341 if opts.cert != None: cert = opts.cert … … 1345 1346 if os.access(cert, os.R_OK): 1346 1347 fid = fedid(file=cert) 1347 if opts.use_fedid == True:1348 user = fid1349 1348 else: 1350 1349 sys.exit("Cannot read certificate (%s)" % cert) 1351 1350 1352 if opts.file:1353 exp_desc = ""1354 try:1355 f = open(opts.file, 'r')1356 for line in f:1357 exp_desc += line1358 f.close()1359 except IOError:1360 sys.exit("Cannot read description file (%s)" %opts.file)1361 else:1362 sys.exit("Must specify an experiment description (--file)")1363 1364 if not opts.master:1365 sys.exit("Must specify a master testbed (--master)")1366 1367 1351 out_certfile = opts.out_certfile 1368 1352 1369 msg = { 1370 'experimentdescription': { 'ns2description': exp_desc }, 1371 'master': opts.master, 1372 'exportProject': { 'localname': opts.project }, 1373 'user' : [ {\ 1374 'userID': pack_id(user), \ 1375 'access': [ { a.type: a.buf } for a in access_keys]\ 1376 } ] 1377 } 1353 msg = { } 1378 1354 1379 1355 if opts.exp_name: … … 1412 1388 print "status: %s" % st 1413 1389 1390 1391 class create(fedd_rpc): 1392 def __init__(self): 1393 fedd_rpc.__init__(self, "Create") 1394 def __call__(self): 1395 access_keys = [] 1396 # Process the options using the customized option parser defined above 1397 parser = fedd_create_opts(access_keys, self.add_ssh_key, 1398 self.add_x509_cert) 1399 1400 (opts, args) = parser.parse_args() 1401 1402 if opts.trusted: 1403 if ( not os.access(opts.trusted, os.R_OK) ) : 1404 sys.exit("Cannot read trusted certificates (%s)" % opts.trusted) 1405 1406 if not opts.project : 1407 parser.error('--project is required') 1408 1409 if opts.debug > 0: opts.tracefile=sys.stderr 1410 1411 (user, cert) = self.get_user_info(access_keys) 1412 1413 if opts.user: user = opts.user 1414 1415 if opts.cert != None: cert = opts.cert 1416 1417 if cert == None: 1418 sys.exit("No certificate given (--cert) or found") 1419 1420 if os.access(cert, os.R_OK): 1421 fid = fedid(file=cert) 1422 if opts.use_fedid == True: 1423 user = fid 1424 else: 1425 sys.exit("Cannot read certificate (%s)" % cert) 1426 1427 if opts.file: 1428 exp_desc = "" 1429 try: 1430 f = open(opts.file, 'r') 1431 for line in f: 1432 exp_desc += line 1433 f.close() 1434 except IOError: 1435 sys.exit("Cannot read description file (%s)" %opts.file) 1436 else: 1437 sys.exit("Must specify an experiment description (--file)") 1438 1439 if not opts.master: 1440 sys.exit("Must specify a master testbed (--master)") 1441 1442 out_certfile = opts.out_certfile 1443 1444 msg = { 1445 'experimentdescription': { 'ns2description': exp_desc }, 1446 'master': opts.master, 1447 'exportProject': { 'localname': opts.project }, 1448 'user' : [ {\ 1449 'userID': pack_id(user), \ 1450 'access': [ { a.type: a.buf } for a in access_keys]\ 1451 } ] 1452 } 1453 1454 if opts.exp_name: 1455 msg['experimentID'] = { 'localname': opts.exp_name } 1456 1457 if opts.debug > 1: print >>sys.stderr, msg 1458 1459 try: 1460 resp_dict = self.do_rpc(msg, 1461 opts.url, opts.transport, cert, opts.trusted, 1462 serialize_only=opts.serialize_only, 1463 tracefile=opts.tracefile) 1464 except self.RPCException, e: 1465 exit_with_fault(\ 1466 {'desc': e.desc, 'errstr': e.errstr, 'code': e.code}) 1467 except RuntimeError, e: 1468 sys.exit("Error processing RPC: %s" % e) 1469 1470 if opts.debug > 1: print >>sys.stderr, resp_dict 1471 1472 ea = resp_dict.get('experimentAccess', None) 1473 if out_certfile and ea and ea.has_key('X509'): 1474 try: 1475 f = open(out_certfile, "w") 1476 print >>f, ea['X509'] 1477 f.close() 1478 except IOError: 1479 sys.exit('Could not write to %s' % out_certfile) 1480 eid = resp_dict.get('experimentID', None) 1481 if eid: 1482 for id in eid: 1483 for k in id.keys(): 1484 print "%s: %s" % (k, id[k]) 1485 st = resp_dict.get('experimentStatus', None) 1486 if st: 1487 print "status: %s" % st 1488 1414 1489 class split(fedd_rpc): 1415 1490 def __init__(self): … … 1749 1824 1750 1825 cmds = {\ 1826 'new': new(),\ 1751 1827 'create': create(),\ 1752 1828 'split': split(),\ -
fedd/federation/experiment_control.py
r4ac0a41 ra3ad8bd 332 332 # Dispatch tables 333 333 self.soap_services = {\ 334 'New': soap_handler('New', self.new_experiment), 334 335 'Create': soap_handler('Create', self.create_experiment), 335 336 'Vtopo': soap_handler('Vtopo', self.get_vtopo), … … 342 343 343 344 self.xmlrpc_services = {\ 345 'New': xmlrpc_handler('New', self.new_experiment), 344 346 'Create': xmlrpc_handler('Create', self.create_experiment), 345 347 'Vtopo': xmlrpc_handler('Vtopo', self.get_vtopo), … … 498 500 for fid in self.accessdb.keys(): 499 501 self.auth.set_attribute(fid, 'create') 502 self.auth.set_attribute(fid, 'new') 500 503 501 504 def read_mapdb(self, file): … … 868 871 } 869 872 870 871 873 def release_access(self, tb, aid, uri=None): 872 874 """ … … 1214 1216 1215 1217 1216 def create_experiment_state(self, fid, req, expid, expcert): 1218 def create_experiment_state(self, fid, req, expid, expcert, 1219 state='starting'): 1217 1220 """ 1218 1221 Create the initial entry in the experiment's state. The expid and … … 1221 1224 includes a suggested local name that is used if possible. If the local 1222 1225 name is already taken by an experiment owned by this user that has 1223 failed, it is overwri utten. Otherwise new letters are added until a1226 failed, it is overwritten. Otherwise new letters are added until a 1224 1227 valid localname is found. The generated local name is returned. 1225 1228 """ … … 1250 1253 'experimentID' : \ 1251 1254 [ { 'localname' : eid }, {'fedid': expid } ], 1252 'experimentStatus': 'starting',1255 'experimentStatus': state, 1253 1256 'experimentAccess': { 'X509' : expcert }, 1254 1257 'owner': fid, … … 1271 1274 'experimentID' : \ 1272 1275 [ { 'localname' : eid }, {'fedid': expid } ], 1273 'experimentStatus': 'starting',1276 'experimentStatus': state, 1274 1277 'experimentAccess': { 'X509' : expcert }, 1275 1278 'owner': fid, … … 1858 1861 1859 1862 1863 def new_experiment(self, req, fid): 1864 """ 1865 The external interface to empty initial experiment creation called from 1866 the dispatcher. 1867 1868 Creates a working directory, splits the incoming description using the 1869 splitter script and parses out the avrious subsections using the 1870 lcasses above. Once each sub-experiment is created, use pooled threads 1871 to instantiate them and start it all up. 1872 """ 1873 if not self.auth.check_attribute(fid, 'new'): 1874 raise service_error(service_error.access, "New access denied") 1875 1876 try: 1877 tmpdir = tempfile.mkdtemp(prefix="split-") 1878 except IOError: 1879 raise service_error(service_error.internal, "Cannot create tmp dir") 1880 1881 try: 1882 access_user = self.accessdb[fid] 1883 except KeyError: 1884 raise service_error(service_error.internal, 1885 "Access map and authorizer out of sync in " + \ 1886 "create_experiment for fedid %s" % fid) 1887 1888 pid = "dummy" 1889 gid = "dummy" 1890 1891 req = req.get('NewRequestBody', None) 1892 if not req: 1893 raise service_error(service_error.req, 1894 "Bad request format (no NewRequestBody)") 1895 1896 # Generate an ID for the experiment (slice) and a certificate that the 1897 # allocator can use to prove they own it. We'll ship it back through 1898 # the encrypted connection. 1899 (expid, expcert) = generate_fedid("test", dir=tmpdir, log=self.log) 1900 1901 #now we're done with the tmpdir, and it should be empty 1902 if self.cleanup: 1903 self.log.debug("[new_experiment]: removing %s" % tmpdir) 1904 os.rmdir(tmpdir) 1905 else: 1906 self.log.debug("[new_experiment]: not removing %s" % tmpdir) 1907 1908 eid = self.create_experiment_state(fid, req, expid, expcert, 1909 state='empty') 1910 1911 # Let users touch the state 1912 self.auth.set_attribute(fid, expid) 1913 self.auth.set_attribute(expid, expid) 1914 # Override fedids can manipulate state as well 1915 for o in self.overrides: 1916 self.auth.set_attribute(o, expid) 1917 1918 rv = { 1919 'experimentID': [ 1920 {'localname' : eid }, { 'fedid': copy.copy(expid) } 1921 ], 1922 'experimentStatus': 'empty', 1923 'experimentAccess': { 'X509' : expcert } 1924 } 1925 1926 return rv 1927 1928 1860 1929 def create_experiment(self, req, fid): 1861 1930 """ -
wsdl/fedd.wsdl
r4ac0a41 ra3ad8bd 32 32 <part name="ReleaseAccessResponseBody" type="xsd1:releaseResponseType"/> 33 33 </message> 34 35 <message name="NewRequestMessage"> 36 <part name="NewRequestBody" type="xsd1:newRequestType"/> 37 </message> 38 39 <message name="NewResponseMessage"> 40 <part name="NewResponseBody" type="xsd1:newResponseType"/> 41 </message> 42 43 34 44 <message name="CreateRequestMessage"> 35 45 <part name="CreateRequestBody" type="xsd1:createRequestType"/> … … 126 136 <fault name="ReleaseAccessFeddFault" message="tns:FaultMessage"/> 127 137 </operation> 138 <operation name="New"> 139 <documentation> 140 A request to create a federated experiment in an empty state so 141 resources can be attached and attributes delegated. On success the 142 identity of the new experiment is returned. 143 </documentation> 144 <input message="tns:NewRequestMessage"/> 145 <output message="tns:NewResponseMessage"/> 146 <fault name="NewFeddFault" message="tns:FaultMessage"/> 147 </operation> 128 148 <operation name="Create"> 129 149 <documentation> … … 257 277 </fault> 258 278 </operation> 279 <operation name="New"> 280 <documentation> 281 The bindings of this operation are straightforward SOAP RPC 1.1. 282 </documentation> 283 <soap:operation soapAction="New"/> 284 <input> 285 <soap:body use="literal" parts="tns:NewRequestBody" 286 namespace="http://www.isi.edu/faber/fedd.wsdl" 287 encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> 288 </input> 289 <output> 290 <soap:body use="literal" parts="tns:NewResponseBody" 291 namespace="http://www.isi.edu/faber/fedd.wsdl" 292 encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> 293 </output> 294 <fault name="NewFeddFault"> 295 <soap:fault use="literal" name="tns:FeddFault" 296 namespace="http://www.isi.edu/faber/fedd.wsdl" 297 encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> 298 </fault> 299 </operation> 259 300 <operation name="Create"> 260 301 <documentation> -
wsdl/fedd_types.xsd
r4ac0a41 ra3ad8bd 63 63 </xsd:annotation> 64 64 <xsd:restriction base="xsd:string"> 65 <xsd:enumeration value="empty"/> 65 66 <xsd:enumeration value="active"/> 66 67 <xsd:enumeration value="starting"/> … … 350 351 <xsd:element name="topdldescription" type="topdl:topologyType"/> 351 352 </xsd:choice> 353 </xsd:complexType> 354 355 <xsd:complexType name="newRequestType"> 356 <xsd:annotation> 357 <xsd:documentation> 358 Request for an experiment to which credentials can be delegated and 359 resources attached. A local name may be included as a human readable 360 accessor, local to this experiment controller. It is a suggestion and 361 may be modified. experimentID can only be a local name. 362 363 Credentials are seed credentials to begin the proof. 364 </xsd:documentation> 365 </xsd:annotation> 366 <xsd:sequence> 367 <xsd:element name="experimentID" type="tns:IDType" minOccurs="0" 368 maxOccurs="1"/> 369 <xsd:element name="credential" type="xsd:base64Binary" minOccurs="0" 370 maxOccurs="unbounded"/> 371 </xsd:sequence> 372 </xsd:complexType> 373 374 <xsd:complexType name="newResponseType"> 375 <xsd:annotation> 376 <xsd:documentation> 377 Result of a new experiment creation. A successful sreation will have 378 an experimentState of "empty", 2 experimentIDs, one a fedid and one a 379 local name, and an experimentAccess that allows the creator to act as 380 the experiment. 381 </xsd:documentation> 382 </xsd:annotation> 383 <xsd:sequence> 384 <xsd:element name="experimentID" type="tns:IDType" minOccurs="0" 385 maxOccurs="unbounded"/> 386 <xsd:element name="experimentStatus" type="tns:statusType"/> 387 <xsd:element name="experimentAccess" type="tns:accessType"/> 388 </xsd:sequence> 352 389 </xsd:complexType> 353 390
Note: See TracChangeset
for help on using the changeset viewer.