Changeset f4f4117 for fedd/fedd_client.py
- Timestamp:
- Oct 20, 2008 5:17:31 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:
- fa19281
- Parents:
- 72ed6e4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/fedd_client.py
r72ed6e4 rf4f4117 6 6 7 7 from fedd_services import * 8 from fedd_internal_services import * 8 9 9 10 from M2Crypto import SSL, X509 … … 259 260 transdict={ 'ssl_context' : context }, 260 261 tracefile=tracefile) 262 method_call = getattr(port, self.method, None) 263 264 if not method_call: 265 loc = feddInternalServiceLocator(); 266 port = loc.getfeddInternalPortType(url, 267 transport=M2Crypto.httpslib.HTTPSConnection, 268 transdict={ 'ssl_context' : context }, 269 tracefile=tracefile) 270 method_call = getattr(port, self.method, None) 271 if not method_call: 272 raise RuntimeError("Can't find method: %s" % self.method) 261 273 262 274 req = self.RequestMessage() … … 587 599 else: print "%s: %s" % (k, id[k]) 588 600 601 class split(fedd_rpc): 602 def __init__(self): 603 fedd_rpc.__init__(self, "Ns2Split") 604 def __call__(self): 605 access_keys = [] 606 # Process the options using the customized option parser defined above 607 parser = fedd_create_opts(access_keys, self.add_ssh_key, 608 self.add_x509_cert) 609 610 (opts, args) = parser.parse_args() 611 612 if opts.trusted != None: 613 if ( not os.access(opts.trusted, os.R_OK) ) : 614 sys.exit("Cannot read trusted certificates (%s)" % opts.trusted) 615 else: 616 parser.error("--trusted is required") 617 618 if opts.debug > 0: opts.tracefile=sys.stderr 619 620 if opts.cert != None: cert = opts.cert 621 622 if cert == None: 623 sys.exit("No certificate given (--cert) or found") 624 625 if os.access(cert, os.R_OK): 626 fid = fedid(file=cert) 627 if opts.use_fedid == True: 628 user = fid 629 else: 630 sys.exit("Cannot read certificate (%s)" % cert) 631 632 if opts.file: 633 exp_desc = "" 634 try: 635 f = open(opts.file, 'r') 636 for line in f: 637 exp_desc += line 638 f.close() 639 except IOError: 640 sys.exit("Cannot read description file (%s)" %opts.file) 641 else: 642 sys.exit("Must specify an experiment description (--file)") 643 644 if not opts.master: 645 sys.exit("Must specify a master testbed (--master)") 646 647 out_certfile = opts.out_certfile 648 649 msg = { 650 'description': { 'ns2description': exp_desc }, 651 'master': opts.master, 652 } 653 654 if opts.debug > 1: print >>sys.stderr, msg 655 656 try: 657 resp_dict = self.do_rpc(msg, 658 opts.url, opts.transport, cert, opts.trusted, 659 serialize_only=opts.serialize_only, 660 tracefile=opts.tracefile) 661 except self.RPCException, e: 662 exit_with_fault(\ 663 {'desc': e.desc, 'errstr': e.errstr, 'code': e.code}) 664 except RuntimeError, e: 665 sys.exit("Error processing RPC: %s" % e) 666 667 if opts.debug > 1: print >>sys.stderr, resp_dict 668 669 out = resp_dict.get('output', None) 670 671 for line in out.splitlines(): 672 print "%s" % line 673 589 674 class access(fedd_rpc): 590 675 def __init__(self): … … 702 787 cmds = {\ 703 788 'create': create(),\ 789 'split': split(),\ 704 790 'access': access(),\ 705 791 'vtopo': exp_data('Vtopo'),\
Note: See TracChangeset
for help on using the changeset viewer.