Changeset 1699 for trunk/packages


Ignore:
Timestamp:
Nov 17, 2008, 1:20:02 PM (16 years ago)
Author:
broder
Message:

Add real caching to consolefs, too

Location:
trunk/packages/invirt-console-server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/invirt-console-server/debian/changelog

    r1610 r1699  
     1invirt-console-server (0.1.0) unstable; urgency=low
     2
     3  * Add real caching to consolefs
     4
     5 -- Evan Broder <broder@mit.edu>  Mon, 17 Nov 2008 13:16:09 -0500
     6
    17invirt-console-server (0.0.13) unstable; urgency=low
    28
  • trunk/packages/invirt-console-server/files/usr/bin/invirt-consolefs

    r1201 r1699  
    2727                """
    2828                super(ConsoleFS, self).__init__(*args, **kw)
    29                 self.lasttime = time()
     29                self.lasttime = 0
     30                self.machines = []
    3031                self.fuse_args.add("allow_other", True)
    3132               
     
    3334               
    3435                syslog(LOG_DEBUG, 'Init complete.')
    35 
     36       
    3637        def make_map(self):
    3738                m = Mapper()
     
    4243                return m
    4344       
    44         def getMachines(self, **kw):
    45                 """Get the list of VMs in the database, clearing the cache if it's
    46                 older than 15 seconds"""
     45        def recache(self):
     46                """Refresh the local cache of VMs if the cache is more than 15 minutes old
     47                """
    4748                if time() - self.lasttime > 15:
    4849                        self.lasttime = time()
    4950                        database.clear_cache()
    50                 return [machine.name for machine in database.Machine.query()]
     51                        self.machines = dict((machine.name, machine) for machine in database.session.query(database.Machine).all())
     52
     53        def getMachines(self, **kw):
     54                """Get the list of VMs in the database"""
     55                self.recache()
     56                return self.machines.keys()
    5157       
    5258        def getMirror(self, machine, path='', **kw):
     
    6874                """Build the ACL for a machine and turn it into a .k5login file
    6975                """
    70                 machine = database.Machine.query().filter_by(name=machine).one()
     76                self.recache()
     77                machine = self.machines[machine]
    7178                users = [acl.user for acl in machine.acl]
    7279                return "\n".join(map(self.userToPrinc, users) + [''])
Note: See TracChangeset for help on using the changeset viewer.