Changeset 1699 for trunk/packages/invirt-console-server/files
- Timestamp:
- Nov 17, 2008, 1:20:02 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/invirt-console-server/files/usr/bin/invirt-consolefs
r1201 r1699 27 27 """ 28 28 super(ConsoleFS, self).__init__(*args, **kw) 29 self.lasttime = time() 29 self.lasttime = 0 30 self.machines = [] 30 31 self.fuse_args.add("allow_other", True) 31 32 … … 33 34 34 35 syslog(LOG_DEBUG, 'Init complete.') 35 36 36 37 def make_map(self): 37 38 m = Mapper() … … 42 43 return m 43 44 44 def getMachines(self, **kw):45 """ Get the list of VMs in the database, clearing the cache if it's46 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 """ 47 48 if time() - self.lasttime > 15: 48 49 self.lasttime = time() 49 50 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() 51 57 52 58 def getMirror(self, machine, path='', **kw): … … 68 74 """Build the ACL for a machine and turn it into a .k5login file 69 75 """ 70 machine = database.Machine.query().filter_by(name=machine).one() 76 self.recache() 77 machine = self.machines[machine] 71 78 users = [acl.user for acl in machine.acl] 72 79 return "\n".join(map(self.userToPrinc, users) + [''])
Note: See TracChangeset
for help on using the changeset viewer.