- Timestamp:
- Apr 28, 2010 9:38:07 AM (15 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
- Children:
- 7e67ab9
- Parents:
- ab847bc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/fedd_client.py
rab847bc r12658df 69 69 self.add_option( "--debug", action="count", dest="debug", 70 70 default=0, help="Set debug. Repeat for more information") 71 self.add_option("--serialize Only", action="store_true",71 self.add_option("--serialize_only", action="store_true", 72 72 dest="serialize_only", default=False, 73 73 help="Print the SOAP request that would be sent and exit") … … 99 99 help="Project to export from master") 100 100 self.add_option("--master", dest="master", 101 help="Master testbed in the federation") 101 help="Master testbed in the federation (pseudo project export)") 102 self.add_option("--service", dest="service", action="append", 103 type="string", default=[], 104 help="Service description name:exporters:importers:attrs") 102 105 103 106 class fedd_split_opts(fedd_create_opts): … … 315 318 if transport == "soap": 316 319 if serialize_only: 317 print self.caller.serialize_soap(req_dict)318 sys.exit(0) 320 print caller.serialize_soap(req_dict) 321 return { } 319 322 else: 320 323 try: … … 331 334 ser = dumps((req_dict,)) 332 335 print ser 333 sys.exit(0) 336 return { } 334 337 else: 335 338 try: … … 908 911 len(resp_dict['vtopo'].get('node', [])), 909 912 file, fmt, opts.neato, opts.labels, opts.pixels) 913 elif opts.serialze_only: 914 sys.exit(0) 910 915 else: 911 916 sys.exit("Bad response. %s" % e.message) … … 1064 1069 self.gen_image(topo, len(topo.get('node', [])), file, fmt, 1065 1070 opts.neato, opts.labels, opts.pixels) 1071 elif opts.serialze_only: 1072 sys.exit(0) 1066 1073 else: 1067 1074 sys.exit("Bad response. %s" % e.message) … … 1418 1425 def __init__(self): 1419 1426 fedd_rpc.__init__(self) 1427 1428 @staticmethod 1429 def parse_service(svc): 1430 terms = svc.split(':') 1431 svcd = { } 1432 if len(terms) < 2 or len(terms[0]) == 0 or len(terms[1]) == 0: 1433 sys.exit("Bad service description '%s': Not enough terms" % svc) 1434 1435 svcd['name'] = terms[0] 1436 svcd['export'] = terms[1].split(",") 1437 if len(terms) > 2 and len(terms[2]) > 0: 1438 svcd['import'] = terms[2].split(",") 1439 if len(terms) > 3 and len(terms[3]) > 0: 1440 svcd['fedAttr'] = [ ] 1441 for t in terms[3].split(","): 1442 i = t.find("=") 1443 if i != -1 : 1444 svcd['fedAttr'].append( 1445 {'attribute': t[0:i], 'value': t[i+1:]}) 1446 else: 1447 sys.exit("Bad service attribute '%s': no equals sign" % t) 1448 return svcd 1449 1420 1450 def __call__(self): 1421 1451 parser = fedd_create_opts() 1422 1452 1423 1453 (opts, args) = parser.parse_args() 1454 1455 svcs = [] 1424 1456 1425 1457 if opts.trusted: … … 1427 1459 sys.exit("Cannot read trusted certificates (%s)" % opts.trusted) 1428 1460 1429 if not opts.project:1430 parser.error('--project is required') 1461 if not (opts.project and opts.master) and not opts.service: 1462 print >>sys.stderr, "Neither master/project nor services requested" 1431 1463 1432 1464 if opts.debug > 0: opts.tracefile=sys.stderr … … 1456 1488 sys.exit("Must specify an experiment description (--file)") 1457 1489 1458 if not opts.master:1459 sys.exit("Must specify a master testbed (--master)")1460 1461 1490 out_certfile = opts.out_certfile 1462 1491 1492 # Fill in svcs here so errors in service specification come before the 1493 # New call is made 1494 if opts.master and opts.project: 1495 svcs.append({ 1496 'name': 'project_export', 1497 'export': [opts.master], 1498 'fedAttr': [ 1499 { 'attribute': 'project', 'value': opts.project }, 1500 ], 1501 }) 1502 1503 svcs.extend([ self.parse_service(s) for s in opts.service]) 1463 1504 msg = { } 1464 1505 … … 1500 1541 elif k =='localname': 1501 1542 e_local = id[k] 1502 1503 msg = { 1504 'experimentdescription': { 'ns2description': exp_desc }, 1505 'service': [ { 1506 'name': 'project_export', 1507 'export': [opts.master], 1508 'fedAttr': [ 1509 { 'attribute': 'project', 'value': opts.project }, 1510 ], 1511 }, ] 1512 } 1543 elif opts.serialize_only: 1544 e_local = "serialize" 1545 msg = { 'experimentdescription': { 'ns2description': exp_desc }, } 1546 1547 if svcs: 1548 msg['service'] = svcs 1513 1549 1514 1550 if e_fedid: … … 1716 1752 1717 1753 if opts.debug > 1: print >>sys.stderr, resp_dict 1718 self.print_response_as_testbed(resp_dict, opts.label) 1754 if not opts.serialize_only: 1755 self.print_response_as_testbed(resp_dict, opts.label) 1719 1756 1720 1757 # Keep requesting experiment status and printing updates to the log until the … … 1792 1829 sys.exit("Error processing RPC: %s" % e) 1793 1830 1794 status = resp_dict.get('experimentStatus', None) 1831 if not opts.serialize_only: 1832 status = resp_dict.get('experimentStatus', None) 1833 else: 1834 status = "active" 1795 1835 log = resp_dict.get('allocationLog', None) 1796 1836 if not status: … … 1865 1905 1866 1906 if opts.debug > 1: print >>sys.stderr, resp_dict 1867 print resp_dict 1868 1869 1907 if not opts.serialize_only: 1908 print resp_dict 1870 1909 1871 1910 cmds = {\
Note: See TracChangeset
for help on using the changeset viewer.