Changeset a3ad8bd for fedd/federation


Ignore:
Timestamp:
Dec 4, 2009 2:21:11 PM (15 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
Children:
c17efe6
Parents:
4ac0a41
Message:

checkpoint, adding new operation - prequel to splitting the create call to allow delegation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/experiment_control.py

    r4ac0a41 ra3ad8bd  
    332332        # Dispatch tables
    333333        self.soap_services = {\
     334                'New': soap_handler('New', self.new_experiment),
    334335                'Create': soap_handler('Create', self.create_experiment),
    335336                'Vtopo': soap_handler('Vtopo', self.get_vtopo),
     
    342343
    343344        self.xmlrpc_services = {\
     345                'New': xmlrpc_handler('New', self.new_experiment),
    344346                'Create': xmlrpc_handler('Create', self.create_experiment),
    345347                'Vtopo': xmlrpc_handler('Vtopo', self.get_vtopo),
     
    498500        for fid in self.accessdb.keys():
    499501            self.auth.set_attribute(fid, 'create')
     502            self.auth.set_attribute(fid, 'new')
    500503
    501504    def read_mapdb(self, file):
     
    868871            }
    869872
    870        
    871873    def release_access(self, tb, aid, uri=None):
    872874        """
     
    12141216
    12151217
    1216     def create_experiment_state(self, fid, req, expid, expcert):
     1218    def create_experiment_state(self, fid, req, expid, expcert,
     1219            state='starting'):
    12171220        """
    12181221        Create the initial entry in the experiment's state.  The expid and
     
    12211224        includes a suggested local name that is used if possible.  If the local
    12221225        name is already taken by an experiment owned by this user that has
    1223         failed, it is overwriutten.  Otherwise new letters are added until a
     1226        failed, it is overwritten.  Otherwise new letters are added until a
    12241227        valid localname is found.  The generated local name is returned.
    12251228        """
     
    12501253                    'experimentID' : \
    12511254                            [ { 'localname' : eid }, {'fedid': expid } ],
    1252                     'experimentStatus': 'starting',
     1255                    'experimentStatus': state,
    12531256                    'experimentAccess': { 'X509' : expcert },
    12541257                    'owner': fid,
     
    12711274                    'experimentID' : \
    12721275                            [ { 'localname' : eid }, {'fedid': expid } ],
    1273                     'experimentStatus': 'starting',
     1276                    'experimentStatus': state,
    12741277                    'experimentAccess': { 'X509' : expcert },
    12751278                    'owner': fid,
     
    18581861
    18591862
     1863    def new_experiment(self, req, fid):
     1864        """
     1865        The external interface to empty initial experiment creation called from
     1866        the dispatcher.
     1867
     1868        Creates a working directory, splits the incoming description using the
     1869        splitter script and parses out the avrious subsections using the
     1870        lcasses above.  Once each sub-experiment is created, use pooled threads
     1871        to instantiate them and start it all up.
     1872        """
     1873        if not self.auth.check_attribute(fid, 'new'):
     1874            raise service_error(service_error.access, "New access denied")
     1875
     1876        try:
     1877            tmpdir = tempfile.mkdtemp(prefix="split-")
     1878        except IOError:
     1879            raise service_error(service_error.internal, "Cannot create tmp dir")
     1880
     1881        try:
     1882            access_user = self.accessdb[fid]
     1883        except KeyError:
     1884            raise service_error(service_error.internal,
     1885                    "Access map and authorizer out of sync in " + \
     1886                            "create_experiment for fedid %s"  % fid)
     1887
     1888        pid = "dummy"
     1889        gid = "dummy"
     1890
     1891        req = req.get('NewRequestBody', None)
     1892        if not req:
     1893            raise service_error(service_error.req,
     1894                    "Bad request format (no NewRequestBody)")
     1895
     1896        # Generate an ID for the experiment (slice) and a certificate that the
     1897        # allocator can use to prove they own it.  We'll ship it back through
     1898        # the encrypted connection.
     1899        (expid, expcert) = generate_fedid("test", dir=tmpdir, log=self.log)
     1900
     1901        #now we're done with the tmpdir, and it should be empty
     1902        if self.cleanup:
     1903            self.log.debug("[new_experiment]: removing %s" % tmpdir)
     1904            os.rmdir(tmpdir)
     1905        else:
     1906            self.log.debug("[new_experiment]: not removing %s" % tmpdir)
     1907
     1908        eid = self.create_experiment_state(fid, req, expid, expcert,
     1909                state='empty')
     1910
     1911        # Let users touch the state
     1912        self.auth.set_attribute(fid, expid)
     1913        self.auth.set_attribute(expid, expid)
     1914        # Override fedids can manipulate state as well
     1915        for o in self.overrides:
     1916            self.auth.set_attribute(o, expid)
     1917
     1918        rv = {
     1919                'experimentID': [
     1920                    {'localname' : eid }, { 'fedid': copy.copy(expid) }
     1921                ],
     1922                'experimentStatus': 'empty',
     1923                'experimentAccess': { 'X509' : expcert }
     1924            }
     1925
     1926        return rv
     1927
     1928
    18601929    def create_experiment(self, req, fid):
    18611930        """
Note: See TracChangeset for help on using the changeset viewer.