Changeset 5f6929a for fedd/federation
- Timestamp:
- Apr 7, 2010 1:53:58 AM (15 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
- Children:
- 7fe81be
- Parents:
- 3e3a5de
- Location:
- fedd/federation
- Files:
-
- 2 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/deter_impl.py
r3e3a5de r5f6929a 5 5 import protogeni_access 6 6 from experiment_control import experiment_control_local 7 from split import split_local7 from ns2topdl import ns2topdl_local 8 8 from util import read_simple_accessdb 9 9 from fedid import fedid … … 101 101 self.get_handler = None 102 102 103 if config.has_section(" splitter"):104 self. splitter = split_local(config, self.auth)105 self.soap_services.update(self. splitter.soap_services)106 self.xmlrpc_services.update(self. splitter.xmlrpc_services)103 if config.has_section("ns2topdl"): 104 self.ns2topdl = ns2topdl_local(config, self.auth) 105 self.soap_services.update(self.ns2topdl.soap_services) 106 self.xmlrpc_services.update(self.ns2topdl.xmlrpc_services) 107 107 108 108 def new_feddservice(config): -
fedd/federation/experiment_control.py
r3e3a5de r5f6929a 184 184 call_StartSegment = service_caller('StartSegment') 185 185 call_TerminateSegment = service_caller('TerminateSegment') 186 call_Ns2 Split = service_caller('Ns2Split')186 call_Ns2Topdl = service_caller('Ns2Topdl') 187 187 188 188 def __init__(self, config=None, auth=None): … … 243 243 "synch_store") 244 244 self.store_url = config.get("experiment_control", "store_url") 245 self.splitter_url = config.get("experiment_control", " splitter_uri")245 self.splitter_url = config.get("experiment_control", "ns2topdl_uri") 246 246 self.fedkit = parse_tarfile_list(\ 247 247 config.get("experiment_control", "fedkit")) … … 268 268 self.state_lock = Lock() 269 269 self.tclsh = "/usr/local/bin/otclsh" 270 self.tcl_splitter = config.get(" splitter", "tcl_splitter") or \270 self.tcl_splitter = config.get("ns2topdl", "tcl_splitter") or \ 271 271 config.get("experiment_control", "tcl_splitter", 272 272 "/usr/testbed/lib/ns2ir/parse.tcl") … … 797 797 # Tweak search order so that if there are entries in access_user that 798 798 # have a project matching the export project, we try them first 799 if export_project and export_project.has_key('localname'):800 pn = export_project['localname']801 802 access_sequence = [ (p, u) for p, u in access_user if p == pn]803 access_sequence.extend([(p, u) for p, u in access_user if p != pn])799 if export_project: 800 access_sequence = [ (p, u) for p, u in access_user \ 801 if p == export_project] 802 access_sequence.extend([(p, u) for p, u in access_user \ 803 if p != export_project]) 804 804 else: 805 805 access_sequence = access_user … … 825 825 } 826 826 827 # If there is a master, and this is it, ask it to export services 828 # XXX move this to export pseudo-service 827 829 if tb == master: 828 # NB, the export_project parameter is a dict that includes829 # the type830 req['exportProject'] = export_project831 830 req['service'] = [ 832 831 { 'name': 'userconfig', 'visibility': 'export'}, … … 922 921 # better error coding 923 922 924 def remote_ splitter(self, uri, desc, master):923 def remote_ns2topdl(self, uri, desc): 925 924 926 925 req = { 927 926 'description' : { 'ns2description': desc }, 928 'master': master,929 'include_fedkit': bool(self.fedkit),930 'include_gatewaykit': bool(self.gatewaykit)931 927 } 932 928 933 r = self.call_Ns2 Split(uri, req, self.cert_file, self.cert_pwd,929 r = self.call_Ns2Topdl(uri, req, self.cert_file, self.cert_pwd, 934 930 self.trusted_certs) 935 931 936 if r.has_key('Ns2 SplitResponseBody'):937 r = r['Ns2 SplitResponseBody']932 if r.has_key('Ns2TopdlResponseBody'): 933 r = r['Ns2TopdlResponseBody'] 938 934 ed = r.get('experimentdescription', None) 939 935 if ed.has_key('topdldescription'): … … 2007 2003 return rv 2008 2004 2005 def get_master_project(self, req): 2006 master= None 2007 export_project = None 2008 for e in [ s for s in req.get('service', []) \ 2009 if s.get('name') == 'project_export']: 2010 for a in e.get('fedAttr', []): 2011 attr = a.get('attribute', None) 2012 if attr == 'testbed': 2013 master = a.get('value', None) 2014 elif attr == 'project': 2015 export_project = a.get('value', None) 2016 2017 return (master, export_project) 2018 2019 2009 2020 2010 2021 def create_experiment(self, req, fid): … … 2103 2114 raise service_error(service_error.server_config, 2104 2115 "Bad key type (%s)" % self.ssh_type) 2105 2106 master = req.get('master', None) 2116 master, export_project = self.get_master_project(req) 2117 # XXX get these out when master and project are optional 2107 2118 if not master: 2108 2119 raise service_error(service_error.req, 2109 2120 "No master testbed label") 2110 export_project = req.get('exportProject', None)2111 2121 if not export_project: 2112 2122 raise service_error(service_error.req, "No export project") 2113 2123 # XXX 2124 2114 2125 # Translate to topdl 2115 2126 if self.splitter_url: … … 2117 2128 self.log.debug("Calling remote splitter at %s" % \ 2118 2129 self.splitter_url) 2119 top = self.remote_splitter(self.splitter_url, 2120 file_content, master) 2130 top = self.remote_ns2topdl(self.splitter_url, file_content) 2121 2131 else: 2122 2132 tclcmd = [self.tclsh, self.tcl_splitter, '-t', '-x', -
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.