Changeset 5f6929a for fedd/federation/ns2topdl.py
- Timestamp:
- Apr 7, 2010 1:53:58 AM (14 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
- Children:
- 7fe81be
- Parents:
- 3e3a5de
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/ns2topdl.py
r3e3a5de r5f6929a 20 20 fl.addHandler(nullHandler()) 21 21 22 class split_local:22 class ns2topdl_local: 23 23 def __init__(self, config=None, auth=None): 24 24 """ 25 25 Intialize the various attributes, most from the config object 26 26 """ 27 self.debug = config.getboolean(" splitter", "debug")28 self.muxmax = config.getint(" splitter", "muxmax", 3)29 self.tclsh = config.get(" splitter", "tclsh",27 self.debug = config.getboolean("ns2topdl", "debug") 28 self.muxmax = config.getint("ns2topdl", "muxmax", 3) 29 self.tclsh = config.get("ns2topdl", "tclsh", 30 30 "/usr/local/bin/otclsh") 31 self.tcl_splitter = config.get(" splitter", "tcl_splitter",31 self.tcl_splitter = config.get("ns2topdl", "tcl_splitter", 32 32 "/usr/testbed/lib/ns2ir/parse.tcl") 33 access_db = config.get(" splitter", "accessdb", None)34 allow_any = config.getboolean(" splitter", "allow_any", False)33 access_db = config.get("ns2topdl", "accessdb", None) 34 allow_any = config.getboolean("ns2topdl", "allow_any", False) 35 35 36 self.log = logging.getLogger("fedd. splitter")37 set_log_level(config, " splitter", self.log)36 self.log = logging.getLogger("fedd.ns2topdl") 37 set_log_level(config, "ns2topdl", self.log) 38 38 self.trace_file = sys.stderr 39 39 40 set_log_level(config, " splitter", self.log)40 set_log_level(config, "ns2topdl", self.log) 41 41 42 42 if auth: … … 44 44 else: 45 45 self.auth = authorizer() 46 self.log.warning("[ splitter] No authorizer passed in, " +\46 self.log.warning("[ns2topdl] No authorizer passed in, " +\ 47 47 "using local one") 48 48 … … 50 50 raise service_error(service_error.internal, 51 51 "Cannot specify both an access database and allow_any " +\ 52 "for splitter")52 "for ns2topdl") 53 53 54 54 if access_db: 55 55 try: 56 read_simple_accessdb(access_db, self.auth, ' split')56 read_simple_accessdb(access_db, self.auth, 'ns2topdl') 57 57 except IOError, e: 58 58 raise service_error(service_error.internal, … … 61 61 raise service_error(service_error.internal, "%s" % e) 62 62 elif allow_any: 63 auth.set_global_attribute(" split")63 auth.set_global_attribute("ns2topdl") 64 64 65 65 66 66 # Dispatch tables 67 67 self.soap_services = {\ 68 'Ns2 Split': soap_handler("Ns2Split", self.run_splitter),68 'Ns2Topdl': soap_handler("Ns2Topdl", self.run_ns2topdl), 69 69 } 70 70 71 71 self.xmlrpc_services = {\ 72 'Ns2 Split': xmlrpc_handler('Ns2Split', self.run_splitter),72 'Ns2Topdl': xmlrpc_handler('Ns2Topdl', self.run_ns2topdl), 73 73 } 74 74 75 def run_ splitter(self, req, fid):75 def run_ns2topdl(self, req, fid): 76 76 """ 77 The external interface to experiment creation called from the 78 dispatcher. 77 The external interface to tcl to topdl translation. 79 78 80 Creates a working directory, splits the incoming description using the 81 splitter script and parses out the avrious subsections using the 82 lcasses above. Once each sub-experiment is created, use pooled threads 83 to instantiate them and start it all up. 79 Creates a working directory, translates the incoming description using 80 the tcl script. 84 81 """ 85 82 86 if not self.auth.check_attribute(fid, ' split'):83 if not self.auth.check_attribute(fid, 'ns2topdl'): 87 84 raise service_error(service_error.access, "Access Denied") 88 85 89 86 try: 90 tmpdir = tempfile.mkdtemp(prefix=" split-")87 tmpdir = tempfile.mkdtemp(prefix="ns2topdl-") 91 88 except IOError: 92 89 raise service_error(service_error.internal, "Cannot create tmp dir") … … 96 93 gid = "dummy" 97 94 eid = "dummy" 95 master = "dummy" 98 96 99 req = req.get('Ns2 SplitRequestBody', None)97 req = req.get('Ns2TopdlRequestBody', None) 100 98 if not req: 101 99 raise service_error(service_error.req, 102 "Bad request format (no Ns2 SplitRequestBody)")100 "Bad request format (no Ns2TopdlRequestBody)") 103 101 # The tcl parser needs to read a file so put the content into that file 104 102 descr=req.get('description', None) … … 119 117 raise service_error(service_error.req, "No description") 120 118 121 master = req.get('master', None)122 if master == None:123 raise service_error(service_error.req, "No master testbed label")124 125 include_fedkit = req.get('include_fedkit', None)126 if include_fedkit == None:127 raise service_error(service_error.req,128 "No federation kit inclusion directive")129 130 119 131 120 tclcmd = [self.tclsh, self.tcl_splitter, '-t', '-x', 132 121 str(self.muxmax), '-m', master] 133 if include_fedkit: tclcmd.append('-k')134 122 tclcmd.extend([pid, gid, eid, tclfile]) 135 123 self.log.debug("Calling splitter %s" % " ".join(tclcmd))
Note: See TracChangeset
for help on using the changeset viewer.