Changeset 7183b48


Ignore:
Timestamp:
Dec 8, 2009 4:50:25 PM (14 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
Children:
7b26c39
Parents:
c17efe6
Message:

Split out experiment creation into two parts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/experiment_control.py

    rc17efe6 r7183b48  
    219219
    220220        self.repodir = config.get("experiment_control", "repodir")
     221        self.repo_url = config.get("experiment_control", "repo_url",
     222                "https://users.isi.deterlab.net:23235");
    221223
    222224        self.exp_stem = "fed-stem"
     
    987989   
    988990
    989     def allocate_resources(self, allocated, master, eid, expid, expcert,
     991    def allocate_resources(self, allocated, master, eid, expid,
    990992            tbparams, topo, tmpdir, alloc_log=None, log_collector=None,
    991993            attrs=None):
     
    18431845            # XXX
    18441846            softmap[pkg] = \
    1845                     "https://users.isi.deterlab.net:23235/%s/%s" %\
    1846                     ( path, dest)
     1847                    "%s/%s/%s" %\
     1848                    ( self.repo_url, path, dest)
    18471849
    18481850            # Allow the individual segments to access the software.
     
    18841886            raise service_error(service_error.internal,
    18851887                    "Access map and authorizer out of sync in " + \
    1886                             "create_experiment for fedid %s"  % fid)
     1888                            "new_experiment for fedid %s"  % fid)
    18871889
    18881890        pid = "dummy"
     
    19371939        to instantiate them and start it all up.
    19381940        """
    1939         if not self.auth.check_attribute(fid, 'create'):
    1940             raise service_error(service_error.access, "Create access denied")
     1941
     1942        req = req.get('CreateRequestBody', None)
     1943        if not req:
     1944            raise service_error(service_error.req,
     1945                    "Bad request format (no CreateRequestBody)")
     1946
     1947        # Get the experiment access
     1948        exp = req.get('experimentID', None)
     1949        if exp:
     1950            if exp.has_key('fedid'):
     1951                key = exp['fedid']
     1952                expid = key
     1953                eid = None
     1954            elif exp.has_key('localname'):
     1955                key = exp['localname']
     1956                eid = key
     1957                expid = None
     1958            else:
     1959                raise service_error(service_error.req, "Unknown lookup type")
     1960        else:
     1961            raise service_error(service_error.req, "No request?")
     1962
     1963        self.check_experiment_access(fid, key)
    19411964
    19421965        try:
     
    19621985        gid = "dummy"
    19631986
    1964         req = req.get('CreateRequestBody', None)
    1965         if not req:
    1966             raise service_error(service_error.req,
    1967                     "Bad request format (no CreateRequestBody)")
    19681987        # The tcl parser needs to read a file so put the content into that file
    19691988        descr=req.get('experimentdescription', None)
     
    19842003            raise service_error(service_error.req, "No experiment description")
    19852004
    1986         # Generate an ID for the experiment (slice) and a certificate that the
    1987         # allocator can use to prove they own it.  We'll ship it back through
    1988         # the encrypted connection.
    1989         (expid, expcert) = generate_fedid("test", dir=tmpdir, log=self.log)
    1990 
    1991         eid = self.create_experiment_state(fid, req, expid, expcert)
     2005        self.state_lock.acquire()
     2006        if self.state.has_key(key):
     2007            for e in self.state[key].get('experimentID',[]):
     2008                if not expid and e.has_key('fedid'):
     2009                    expid = e['fedid']
     2010                elif not eid and e.has_key('localname'):
     2011                    eid = e['localname']
     2012        self.state_lock.release()
     2013
     2014        if not (eid and expid):
     2015            raise service_error(service_error.internal,
     2016                    "Cannot find local experiment info!?")
     2017
    19922018        try:
    19932019            # This catches exceptions to clear the placeholder if necessary
     
    21612187        alloc_log.addHandler(h)
    21622188       
    2163         # XXX
    2164         url_base = 'https://users.isi.deterlab.net:23235'
    21652189        attrs = [
    21662190                {
    21672191                    'attribute': 'ssh_pubkey',
    21682192                    'value': '%s/%s/config/%s' % \
    2169                             (url_base, expid, gw_pubkey_base)
     2193                            (self.repo_url, expid, gw_pubkey_base)
    21702194                },
    21712195                {
    21722196                    'attribute': 'ssh_secretkey',
    21732197                    'value': '%s/%s/config/%s' % \
    2174                             (url_base, expid, gw_secretkey_base)
     2198                            (self.repo_url, expid, gw_secretkey_base)
    21752199                },
    21762200                {
    21772201                    'attribute': 'hosts',
    21782202                    'value': '%s/%s/config/hosts' % \
    2179                             (url_base, expid)
     2203                            (self.repo_url, expid)
    21802204                },
    21812205                {
     
    21872211        # Start a thread to do the resource allocation
    21882212        t  = Thread(target=self.allocate_resources,
    2189                 args=(allocated, master, eid, expid, expcert, tbparams,
     2213                args=(allocated, master, eid, expid, tbparams,
    21902214                    topo, tmpdir, alloc_log, alloc_collector, attrs),
    21912215                name=eid)
     
    21972221                ],
    21982222                'experimentStatus': 'starting',
    2199                 'experimentAccess': { 'X509' : expcert }
    22002223            }
    22012224
     
    22502273
    22512274    def get_handler(self, path, fid):
     2275        self.log.info("Get handler %s %s" % (path, fid))
    22522276        if self.auth.check_attribute(fid, path):
    22532277            return ("%s/%s" % (self.repodir, path), "application/binary")
Note: See TracChangeset for help on using the changeset viewer.