Ignore:
Timestamp:
Sep 8, 2009 5:57:00 PM (15 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-2.00, version-3.01, version-3.02
Children:
40dd8c1
Parents:
430e98d
Message:

better logging and cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/access.py

    r430e98d rf07fa49  
    2222
    2323import topdl
     24import list_log
    2425import httplib
    2526import tempfile
     
    782783                        msg = { 'ReleaseProjectRequestBody' : msg}
    783784                        self.allocate_project.release_project(msg)
     785                # And remove the access cert
     786                cf = "%s/%s.pem" % (self.certdir, aid)
     787                self.log.debug("Removing %s" % cf)
     788                os.remove(cf)
    784789                return { 'allocID': req['allocID'] }
    785790            else:
     
    13401345                user = self.allocation[aid].get('user', None)
    13411346                self.allocation[aid]['experiment'] = ename
     1347                self.allocation[aid]['log'] = [ ]
     1348                # Create a logger that logs to the experiment's state object as
     1349                # well as to the main log file.
     1350                alloc_log = logging.getLogger('fedd.access.%s' % ename)
     1351                h = logging.StreamHandler(
     1352                        list_log.list_log(self.allocation[aid]['log']))
     1353                # XXX: there should be a global one of these rather than
     1354                # repeating the code.
     1355                h.setFormatter(logging.Formatter(
     1356                    "%(asctime)s %(name)s %(message)s",
     1357                            '%d %b %y %H:%M:%S'))
     1358                alloc_log.addHandler(h)
    13421359                self.write_state()
    13431360            self.state_lock.release()
     
    13571374            self.generate_ns2(topo, expfile,
    13581375                    "/proj/%s/software/%s/" % (proj, ename), master)
     1376
    13591377            starter = self.start_segment(keyfile=self.ssh_privkey_file,
    1360                     debug=self.create_debug)
     1378                    debug=self.create_debug, log=alloc_log)
    13611379            rv = starter(self, ename, proj, user, expfile, tmpdir)
    13621380        except service_error, e:
     
    13731391
    13741392        if rv:
    1375             return { 'allocID': req['allocID'] }
     1393            # Grab the log (this is some anal locking, but better safe than
     1394            # sorry)
     1395            self.state_lock.acquire()
     1396            logv = "".join(self.allocation[aid]['log'])
     1397            self.state_lock.release()
     1398
     1399            return { 'allocID': req['allocID'], 'allocationLog': logv }
    13761400        elif err:
    13771401            raise service_error(service_error.federant,
Note: See TracChangeset for help on using the changeset viewer.