Changeset f76d3d7
- Timestamp:
- Jun 30, 2009 6:09:32 PM (15 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
- Children:
- 7a1918e
- Parents:
- b57df44
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/fedd_client.py
rb57df44 rf76d3d7 425 425 426 426 427 # Querying experiment data follows the same control flow regardless of the 428 # specific data retrieved. This class encapsulates that control flow. 429 class simple_info(fedd_rpc): 430 def __init__(self): 431 """ 432 Specialize the class for the type of data requested (op) 433 """ 434 435 fedd_rpc.__init__(self, 'Info') 436 437 def print_xml(self, d, out=sys.stdout): 438 """ 439 Print the retrieved data is a simple xml representation of the dict. 440 """ 441 str = "<%s>\n" % self.xml 442 for t in ('node', 'lan'): 443 if d.has_key(t): 444 for x in d[t]: 445 str += "<%s>" % t 446 for k in x.keys(): 447 str += "<%s>%s</%s>" % (k, x[k],k) 448 str += "</%s>\n" % t 449 str+= "</%s>" % self.xml 450 print >>out, str 451 452 def __call__(self): 453 """ 454 The control flow. Compose the request and print the response. 455 """ 456 # Process the options using the customized option parser defined above 457 parser = fedd_exp_data_opts() 458 459 (opts, args) = parser.parse_args() 460 461 if opts.trusted: 462 if ( not os.access(opts.trusted, os.R_OK) ) : 463 sys.exit("Cannot read trusted certificates (%s)" % opts.trusted) 464 465 if opts.debug > 0: opts.tracefile=sys.stderr 466 467 (user, cert) = self.get_user_info([]) 468 469 if opts.cert != None: cert = opts.cert 470 471 if cert == None: 472 sys.exit("No certificate given (--cert) or found") 473 474 if os.access(cert, os.R_OK): 475 fid = fedid(file=cert) 476 else: 477 sys.exit("Cannot read certificate (%s)" % cert) 478 479 if opts.exp_name and opts.exp_certfile: 480 sys.exit("Only one of --experiment_cert and " +\ 481 "--experiment_name permitted"); 482 483 if opts.exp_certfile: 484 exp_id = { 'fedid': fedid(file=opts.exp_certfile) } 485 486 if opts.exp_name: 487 exp_id = { 'localname' : opts.exp_name } 488 489 req = { 'experiment': exp_id } 490 491 status = "active" 492 try: 493 resp_dict = self.do_rpc(req, 494 opts.url, opts.transport, cert, opts.trusted, 495 serialize_only=opts.serialize_only, 496 tracefile=opts.tracefile) 497 except self.RPCException, e: 498 if e.code == 5: 499 status = "swapping" 500 elif e.code == 1: 501 status = "inactive" 502 else: 503 status = "unknown" 504 except RuntimeError, e: 505 print e 506 sys.exit("Error processing RPC: %s" % e) 507 508 print status 509 510 427 511 class image(fedd_rpc): 428 512 def __init__(self, op): … … 1125 1209 'ns_image': ns_image('Ns2Split'),\ 1126 1210 'info': exp_data('Info'),\ 1211 'status': simple_info(),\ 1127 1212 'terminate': terminate(),\ 1128 1213 }
Note: See TracChangeset
for help on using the changeset viewer.