Changeset 5f6929a for fedd/federation


Ignore:
Timestamp:
Apr 7, 2010 1:53:58 AM (15 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
Children:
7fe81be
Parents:
3e3a5de
Message:

Two changes at once

Remove master and export project from the create request and rename the splitter external interface into a translation interface. The export_project pseudo service is staring.

Also start removeing some deprecated fields.

Location:
fedd/federation
Files:
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • fedd/federation/deter_impl.py

    r3e3a5de r5f6929a  
    55import protogeni_access
    66from experiment_control import experiment_control_local
    7 from split import split_local
     7from ns2topdl import ns2topdl_local
    88from util import read_simple_accessdb
    99from fedid import fedid
     
    101101                    self.get_handler = None
    102102
    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)
    107107
    108108def new_feddservice(config):
  • fedd/federation/experiment_control.py

    r3e3a5de r5f6929a  
    184184    call_StartSegment = service_caller('StartSegment')
    185185    call_TerminateSegment = service_caller('TerminateSegment')
    186     call_Ns2Split = service_caller('Ns2Split')
     186    call_Ns2Topdl = service_caller('Ns2Topdl')
    187187
    188188    def __init__(self, config=None, auth=None):
     
    243243                "synch_store")
    244244        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")
    246246        self.fedkit = parse_tarfile_list(\
    247247                config.get("experiment_control", "fedkit"))
     
    268268        self.state_lock = Lock()
    269269        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 \
    271271                config.get("experiment_control", "tcl_splitter",
    272272                        "/usr/testbed/lib/ns2ir/parse.tcl")
     
    797797        # Tweak search order so that if there are entries in access_user that
    798798        # 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])
    804804        else:
    805805            access_sequence = access_user
     
    825825                    }
    826826
     827            # If there is a master, and this is it, ask it to export services
     828            # XXX move this to export pseudo-service
    827829            if tb == master:
    828                 # NB, the export_project parameter is a dict that includes
    829                 # the type
    830                 req['exportProject'] = export_project
    831830                req['service'] = [
    832831                        { 'name': 'userconfig', 'visibility': 'export'},
     
    922921        # better error coding
    923922
    924     def remote_splitter(self, uri, desc, master):
     923    def remote_ns2topdl(self, uri, desc):
    925924
    926925        req = {
    927926                'description' : { 'ns2description': desc },
    928                 'master': master,
    929                 'include_fedkit': bool(self.fedkit),
    930                 'include_gatewaykit': bool(self.gatewaykit)
    931927            }
    932928
    933         r = self.call_Ns2Split(uri, req, self.cert_file, self.cert_pwd,
     929        r = self.call_Ns2Topdl(uri, req, self.cert_file, self.cert_pwd,
    934930                self.trusted_certs)
    935931
    936         if r.has_key('Ns2SplitResponseBody'):
    937             r = r['Ns2SplitResponseBody']
     932        if r.has_key('Ns2TopdlResponseBody'):
     933            r = r['Ns2TopdlResponseBody']
    938934            ed = r.get('experimentdescription', None)
    939935            if ed.has_key('topdldescription'):
     
    20072003        return rv
    20082004
     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
    20092020
    20102021    def create_experiment(self, req, fid):
     
    21032114                raise service_error(service_error.server_config,
    21042115                        "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
    21072118            if not master:
    21082119                raise service_error(service_error.req,
    21092120                        "No master testbed label")
    2110             export_project = req.get('exportProject', None)
    21112121            if not export_project:
    21122122                raise service_error(service_error.req, "No export project")
    2113            
     2123            # XXX
     2124
    21142125            # Translate to topdl
    21152126            if self.splitter_url:
     
    21172128                self.log.debug("Calling remote splitter at %s" % \
    21182129                        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)
    21212131            else:
    21222132                tclcmd = [self.tclsh, self.tcl_splitter, '-t', '-x',
  • fedd/federation/ns2topdl.py

    r3e3a5de r5f6929a  
    2020fl.addHandler(nullHandler())
    2121
    22 class split_local:
     22class ns2topdl_local:
    2323    def __init__(self, config=None, auth=None):
    2424        """
    2525        Intialize the various attributes, most from the config object
    2626        """
    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",
    3030                "/usr/local/bin/otclsh")
    31         self.tcl_splitter = config.get("splitter", "tcl_splitter",
     31        self.tcl_splitter = config.get("ns2topdl", "tcl_splitter",
    3232                "/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)
    3535
    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)
    3838        self.trace_file = sys.stderr
    3939
    40         set_log_level(config, "splitter", self.log)
     40        set_log_level(config, "ns2topdl", self.log)
    4141
    4242        if auth:
     
    4444        else:
    4545            self.auth = authorizer()
    46             self.log.warning("[splitter] No authorizer passed in, " +\
     46            self.log.warning("[ns2topdl] No authorizer passed in, " +\
    4747                    "using local one")
    4848
     
    5050            raise service_error(service_error.internal,
    5151                    "Cannot specify both an access database and allow_any " +\
    52                             "for splitter")
     52                            "for ns2topdl")
    5353       
    5454        if access_db:
    5555            try:
    56                 read_simple_accessdb(access_db, self.auth, 'split')
     56                read_simple_accessdb(access_db, self.auth, 'ns2topdl')
    5757            except IOError, e:
    5858                raise service_error(service_error.internal,
     
    6161                raise service_error(service_error.internal, "%s" % e)
    6262        elif allow_any:
    63             auth.set_global_attribute("split")
     63            auth.set_global_attribute("ns2topdl")
    6464
    6565
    6666        # Dispatch tables
    6767        self.soap_services = {\
    68                 'Ns2Split': soap_handler("Ns2Split", self.run_splitter),
     68                'Ns2Topdl': soap_handler("Ns2Topdl", self.run_ns2topdl),
    6969        }
    7070
    7171        self.xmlrpc_services = {\
    72                 'Ns2Split': xmlrpc_handler('Ns2Split', self.run_splitter),
     72                'Ns2Topdl': xmlrpc_handler('Ns2Topdl', self.run_ns2topdl),
    7373        }
    7474
    75     def run_splitter(self, req, fid):
     75    def run_ns2topdl(self, req, fid):
    7676        """
    77         The external interface to experiment creation called from the
    78         dispatcher.
     77        The external interface to tcl to topdl translation.
    7978
    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.
    8481        """
    8582
    86         if not self.auth.check_attribute(fid, 'split'):
     83        if not self.auth.check_attribute(fid, 'ns2topdl'):
    8784            raise service_error(service_error.access, "Access Denied")
    8885
    8986        try:
    90             tmpdir = tempfile.mkdtemp(prefix="split-")
     87            tmpdir = tempfile.mkdtemp(prefix="ns2topdl-")
    9188        except IOError:
    9289            raise service_error(service_error.internal, "Cannot create tmp dir")
     
    9693        gid = "dummy"
    9794        eid = "dummy"
     95        master = "dummy"
    9896
    99         req = req.get('Ns2SplitRequestBody', None)
     97        req = req.get('Ns2TopdlRequestBody', None)
    10098        if not req:
    10199            raise service_error(service_error.req,
    102                     "Bad request format (no Ns2SplitRequestBody)")
     100                    "Bad request format (no Ns2TopdlRequestBody)")
    103101        # The tcl parser needs to read a file so put the content into that file
    104102        descr=req.get('description', None)
     
    119117            raise service_error(service_error.req, "No description")
    120118
    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        
    130119       
    131120        tclcmd = [self.tclsh, self.tcl_splitter, '-t', '-x',
    132121            str(self.muxmax), '-m', master]
    133         if include_fedkit: tclcmd.append('-k')
    134122        tclcmd.extend([pid, gid, eid, tclfile])
    135123        self.log.debug("Calling splitter %s" % " ".join(tclcmd))
Note: See TracChangeset for help on using the changeset viewer.