Changeset 1728 for trunk/packages
- Timestamp:
- Nov 21, 2008, 4:16:38 AM (16 years ago)
- Location:
- trunk/packages/invirt-remote-server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/invirt-remote-server/debian/changelog
r1724 r1728 1 invirt-remote-server (0.1.3) unstable; urgency=low 2 3 * Switched to using "raw" select expressions instead of using the ORM; 4 allows the same speed as the old object-based system but without any 5 caching necessary. 6 7 -- Quentin Smith <quentin@mit.edu> Fri, 21 Nov 2008 04:15:50 -0500 8 1 9 invirt-remote-server (0.1.2) unstable; urgency=low 2 10 -
trunk/packages/invirt-remote-server/files/usr/sbin/invirt-remconffs
r1726 r1728 6 6 from syslog import * 7 7 from time import time 8 import sqlalchemy as sa 8 9 9 10 from invirt import database … … 28 29 """ 29 30 super(RemConfFS, self).__init__(*args, **kw) 30 self.lasttime = 031 31 self.fuse_args.add("allow_other", True) 32 32 … … 43 43 return m 44 44 45 def recache(self):46 if time() - self.lasttime > 5:47 self.lasttime = time()48 database.clear_cache()49 self.machines = dict((machine.name, machine) for machine in database.session.query(database.Machine).all())50 51 45 def getroot(self, **kw): 52 46 return ['acl', 'conf'] … … 55 49 """Build the ACL file for a machine 56 50 """ 57 self.recache() 58 machine = self.machines[machine] 59 users = [acl.user for acl in machine.acl] 60 return "\n".join(map(self.userToPrinc, users) 51 s = sa.sql.select([database.machine_access_table.c.user], # Field to select from 52 sa.sql.and_( # where clause 53 database.machine_table.c.machine_id==database.machine_access_table.c.machine_id, # join field 54 database.machine_table.c.name == machine), # filter field 55 from_obj=[database.machine_access_table, database.machine_table]) # from tables 56 users = [self.userToPrinc(acl[0]) for acl in 57 database.session.execute(s)] 58 return "\n".join(users 61 59 + ['include /etc/remctl/acl/web', 62 60 '']) … … 71 69 72 70 def getmachines(self, **kw): 73 """Get the list of VMs in the database, clearing the cache if it's 74 older than 15 seconds""" 75 self.recache() 76 return self.machines.keys() 71 """Get the list of VMs in the database. Does not cache to prevent race conditions.""" 72 return list(row[0] for row in database.session.execute(sa.sql.select([database.Machine.c.name]))) 77 73 78 74 def userToPrinc(self, user):
Note: See TracChangeset
for help on using the changeset viewer.