- Timestamp:
- Oct 20, 2008 5:17:31 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:
- fa19281
- Parents:
- 72ed6e4
- Location:
- fedd
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/fedd.py
r72ed6e4 rf4f4117 16 16 from fedd_util import fedd_ssl_context, fedid 17 17 from fedd_deter_impl import new_feddservice 18 from fedd_services import ns0 18 19 from service_error import * 19 20 … … 35 36 A SafeConfig parser with a more forgiving get attribute 36 37 """ 38 39 def safe_get(self, sect, opt, method, default=None): 40 """ 41 If the option is present, return it, otherwise the default. 42 """ 43 if self.has_option(sect, opt): return method(self, sect, opt) 44 else: return default 45 37 46 def get(self, sect, opt, default=None): 38 47 """ … … 41 50 It's more like getattr than get. 42 51 """ 43 if self.has_option(sect, opt): 44 return SafeConfigParser.get(self, sect, opt) 45 else: 46 return default 52 53 return self.safe_get(sect, opt, SafeConfigParser.get, default) 54 55 def getint(self, sect, opt, default=0): 56 """ 57 Returns the selected option as an int or a default. 58 """ 59 60 return self.safe_get(sect, opt, SafeConfigParser.getint, default) 61 62 def getfloat(self, sect, opt, default=0.0): 63 """ 64 Returns the selected option as an int or a default. 65 """ 66 67 return self.safe_get(sect, opt, SafeConfigParser.getfloat, default) 68 69 def getboolean(self, sect, opt, default=False): 70 """ 71 Returns the selected option as a boolean or a default. 72 """ 73 74 return self.safe_get(sect, opt, SafeConfigParser.getboolean, default) 47 75 48 76 class fedd_server(ThreadingSSLServer): -
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'),\ -
fedd/fedd_deter_impl.py
r72ed6e4 rf4f4117 1 1 #!/usr/local/bin/python 2 2 3 from fedd_access import * 4 from fedd_experiment_control import * 3 from fedd_access import fedd_access 4 from fedd_experiment_control import fedd_experiment_control_local 5 from fedd_split import fedd_split_local 5 6 6 7 class fedd_deter_impl: … … 37 38 self.xmlrpc_services.update(self.experiment.xmlrpc_services) 38 39 40 if config.has_section("splitter"): 41 self.splitter = fedd_split_local(config) 42 self.soap_services.update(self.splitter.soap_services) 43 self.xmlrpc_services.update(self.splitter.xmlrpc_services) 44 39 45 def new_feddservice(config): 40 46 return fedd_deter_impl(config) -
fedd/fedd_experiment_control.py
r72ed6e4 rf4f4117 192 192 self.scripts_dir = config.get("experiment_control", 193 193 "federation_script_dir") 194 self.splitter_url = config.get("experiment_control", "splitter_url") 194 195 else: 195 196 self.debug = False 196 197 self.state_filename = None 197 198 self.scripts_dir = "/users/faber/testbed/federation" 199 self.splitter_url = None 198 200 199 201 # XXX … … 908 910 if key: 909 911 tbparam[tb][key]= a['value'] 912 913 def remote_splitter(self, uri, desc, master): 914 915 req = { 916 'description' : { 'ns2description': desc }, 917 'master': master, 918 } 919 920 # No retry loop here. Proxy servers must correctly authenticate 921 # themselves without help 922 try: 923 ctx = fedd_ssl_context(self.cert_file, 924 self.trusted_certs, password=self.cert_pwd) 925 except SSL.SSLError: 926 raise service_error(service_error.server_config, 927 "Server certificates misconfigured") 928 929 loc = feddInternalServiceLocator(); 930 port = loc.getfeddInternalPortType(uri, 931 transport=M2Crypto.httpslib.HTTPSConnection, 932 transdict={ 'ssl_context' : ctx }) 933 934 # Reconstruct the full request message 935 msg = Ns2SplitRequestMessage() 936 msg.set_element_Ns2SplitRequestBody( 937 pack_soap(msg, "Ns2SplitRequestBody", req)) 938 939 try: 940 resp = port.Ns2Split(msg) 941 except ZSI.ParseException, e: 942 raise service_error(service_error.req, 943 "Bad format message (XMLRPC??): %s" % 944 str(e)) 945 r = unpack_soap(resp) 946 if r.has_key('Ns2SplitResponseBody'): 947 r = r['Ns2SplitResponseBody'] 948 if r.has_key('output'): 949 return r['output'].splitlines() 950 else: 951 raise service_error(service_error.proxy, 952 "Bad splitter response (no output)") 953 else: 954 raise service_error(service_error.proxy, "Bad splitter response") 910 955 911 956 class current_testbed: … … 1408 1453 raise service_error(service_error.req, "No master testbed label") 1409 1454 1410 1411 tclcmd = [self.tclsh, self.tcl_splitter, '-s', '-x', 1412 str(self.muxmax), '-m', master, pid, gid, eid, tclfile] 1413 tclparser = Popen(tclcmd, stdout=PIPE) 1455 if self.splitter_url: 1456 split_data = self.remote_splitter(self.splitter_url, file_content, 1457 master) 1458 else: 1459 tclcmd = [self.tclsh, self.tcl_splitter, '-s', '-x', 1460 str(self.muxmax), '-m', master, pid, gid, eid, tclfile] 1461 tclparser = Popen(tclcmd, stdout=PIPE) 1462 split_data = tclparser.stdout 1414 1463 1415 1464 allocated = { } # Testbeds we can access … … 1432 1481 1433 1482 # Worling on the split data 1434 for line in tclparser.stdout:1483 for line in split_data: 1435 1484 line = line.rstrip() 1436 1485 if parse_current_testbed(line, master, allocated, tbparams): -
fedd/fedd_split.py
r72ed6e4 rf4f4117 43 43 Intialize the various attributes, most from the config object 44 44 """ 45 self.debug = config.create_debug 45 if config.has_section("splitter"): 46 self.debug = config.getboolean("splitter", "debug") 47 self.muxmax = config.getint("splitter", "muxmax", 3) 48 else: 49 self.debug = False 50 self.muxmax = 3 51 46 52 self.log = logging.getLogger("fedd.splitter") 47 53 self.tclsh = "/usr/local/bin/otclsh" … … 82 88 pid = "dummy" 83 89 gid = "dummy" 90 eid = "dummy" 84 91 85 92 req = req.get('Ns2SplitRequestBody', None) … … 88 95 "Bad request format (no Ns2SplitRequestBody)") 89 96 # The tcl parser needs to read a file so put the content into that file 90 descr=req.get(' experimentdescription', None)97 descr=req.get('description', None) 91 98 if descr: 92 99 file_content=descr.get('ns2description', None) … … 103 110 "Only ns2descriptions supported") 104 111 else: 105 raise service_error(service_error.req, "No experimentdescription")112 raise service_error(service_error.req, "No description") 106 113 107 114 master = req.get('master', None) … … 114 121 tclparser = Popen(tclcmd, stdout=PIPE) 115 122 123 out = "" 116 124 # Package up the split data 117 125 for line in tclparser.stdout:
Note: See TracChangeset
for help on using the changeset viewer.