- Timestamp:
- Nov 17, 2008, 1:05:51 PM (16 years ago)
- Location:
- trunk/packages/invirt-remote-server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/invirt-remote-server/debian/changelog
r1665 r1697 1 invirt-remote-server (0.1.0) unstable; urgency=low 2 3 * Add real caching to remconffs 4 5 -- Evan Broder <broder@mit.edu> Mon, 17 Nov 2008 13:05:32 -0500 6 1 7 invirt-remote-server (0.0.18) unstable; urgency=low 2 8 -
trunk/packages/invirt-remote-server/files/usr/sbin/invirt-remconffs
r1176 r1697 19 19 | `-- machinen 20 20 `-- conf 21 21 22 22 The machine list and the acls are drawn from a database. 23 23 """ … … 28 28 """ 29 29 super(RemConfFS, self).__init__(*args, **kw) 30 self.lasttime = time()30 self.lasttime = 0 31 31 self.fuse_args.add("allow_other", True) 32 32 … … 34 34 35 35 syslog(LOG_DEBUG, 'Init complete.') 36 37 def make_map(self): 38 m = Mapper() 39 m.connect('', controller='getroot') 40 m.connect('acl', controller='getmachines') 41 m.connect('acl/:machine', controller='getacl') 42 m.connect('conf', controller='getconf') 43 return m 44 45 def getroot(self, **kw): 46 return ['acl', 'conf'] 47 36 37 def make_map(self): 38 m = Mapper() 39 m.connect('', controller='getroot') 40 m.connect('acl', controller='getmachines') 41 m.connect('acl/:machine', controller='getacl') 42 m.connect('conf', controller='getconf') 43 return m 44 45 def recache(self): 46 if time() - self.lasttime > 15: 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 def getroot(self, **kw): 52 return ['acl', 'conf'] 53 48 54 def getacl(self, machine, **kw): 49 55 """Build the ACL file for a machine 50 56 """ 51 machine = database.Machine.query().filter_by(name=machine).one() 57 self.recache() 58 machine = self.machines[machine] 52 59 users = [acl.user for acl in machine.acl] 53 60 return "\n".join(map(self.userToPrinc, users) 54 61 + ['include /etc/remctl/acl/web', 55 56 62 '']) 63 57 64 def getconf(self, **kw): 58 65 """Build the master conf file, with all machines … … 66 73 """Get the list of VMs in the database, clearing the cache if it's 67 74 older than 15 seconds""" 68 if time() - self.lasttime > 15: 69 self.lasttime = time() 70 database.clear_cache() 71 return [machine.name for machine in database.session.query(database.Machine).all()] 72 75 self.recache() 76 return self.machines.keys() 77 73 78 def userToPrinc(self, user): 74 79 """Convert Kerberos v4-style names to v5-style and append a default … … 85 90 if __name__ == '__main__': 86 91 database.connect() 87 92 routefs.main(RemConfFS)
Note: See TracChangeset
for help on using the changeset viewer.