remconffs: cat conf-files together
[invirt/packages/invirt-remote.git] / files / usr / sbin / sipb-xen-remconffs
index 03099d6..df07f54 100755 (executable)
@@ -104,19 +104,13 @@ class RemConfFS(Fuse):
                                 + ['include /etc/remctl/acl/web',
                                    ''])
                
                                 + ['include /etc/remctl/acl/web',
                                    ''])
                
-       def getconf(self, machine_name):
-               """Build the command file for a machine
+       def getconf(self):
+               """Build the master conf file, with all machines
                """
                """
-               return ("control %s /usr/sbin/sipb-xen-remote-proxy-control"
-                       " /etc/remctl/sipb-xen-auto/acl/%s\n"
-                       % (machine_name, machine_name))
-               
-       def getfile(self, dir, machine_name):
-               """Build the ACL or command file for a machine
-               """
-               if dir == 'acl':    return self.getacl(machine_name)
-               if dir == 'conf.d': return self.getconf(machine_name)
-               raise "this shouldn't happen"
+               return '\n'.join("control %s /usr/sbin/sipb-xen-remote-proxy-control"
+                                " /etc/remctl/remconffs/acl/%s"
+                                % (machine_name, machine_name)
+                                for machine_name in self.getMachines())+'\n'
        
        def userToPrinc(self, user):
                """Convert Kerberos v4-style names to v5-style and append a default
        
        def userToPrinc(self, user):
                """Convert Kerberos v4-style names to v5-style and append a default
@@ -155,18 +149,23 @@ class RemConfFS(Fuse):
                        st.st_mode = stat.S_IFDIR | 0755
                        st.st_nlink = 2
                elif depth == 1:
                        st.st_mode = stat.S_IFDIR | 0755
                        st.st_nlink = 2
                elif depth == 1:
-                       if parts[0] not in ('acl', 'conf.d'):
+                       if parts[0] == 'acl':
+                               st.st_mode = stat.S_IFDIR | 0755
+                               st.st_nlink = 2
+                       elif parts[0] == 'conf':
+                               st.st_mode = stat.S_IFREG | 0444
+                               st.st_nlink = 1
+                               st.st_size = len(self.getconf())
+                       else:
                                return -errno.ENOENT
                                return -errno.ENOENT
-                       st.st_mode = stat.S_IFDIR | 0755
-                       st.st_nlink = 2
                elif depth == 2:
                elif depth == 2:
-                       if parts[0] not in ('acl', 'conf.d'):
+                       if parts[0] != 'acl':
                                return -errno.ENOENT
                        if parts[1] not in self.getMachines():
                                return -errno.ENOENT
                        st.st_mode = stat.S_IFREG | 0444
                        st.st_nlink = 1
                                return -errno.ENOENT
                        if parts[1] not in self.getMachines():
                                return -errno.ENOENT
                        st.st_mode = stat.S_IFREG | 0444
                        st.st_nlink = 1
-                       st.st_size = len(self.getfile(parts[0], parts[1]))
+                       st.st_size = len(self.getacl(parts[1]))
 
                return st.toTuple()
        
 
                return st.toTuple()
        
@@ -190,9 +189,9 @@ class RemConfFS(Fuse):
                parts, depth = parse(path)
 
                if depth == 0:
                parts, depth = parse(path)
 
                if depth == 0:
-                       contents = ('acl', 'conf.d')
+                       contents = ('acl', 'conf')
                elif depth == 1:
                elif depth == 1:
-                       if parts[0] in ('acl', 'conf.d'):
+                       if parts[0] == 'acl':
                                contents = self.getMachines()
                        else:
                                return -errno.ENOENT
                                contents = self.getMachines()
                        else:
                                return -errno.ENOENT
@@ -211,16 +210,15 @@ class RemConfFS(Fuse):
                
                parts, depth = parse(path)
                
                
                parts, depth = parse(path)
                
-               # If the depth is not 2, then either it's a directory or the file
-               # doesn't exist
-               # (realistically this doesn't appear to ever happen)
-               if getDepth(path) != 2:
-                       return -errno.ENOENT
-               elif parts[1] in self.getMachines():
-                       if parts[0] == 'acl':
+               if depth == 0:
+                       return -errno.EISDIR
+               elif parts[0] == 'conf':
+                       return self.getconf()[offset:offset+length]
+               elif parts[0] == 'acl':
+                       if depth == 1:
+                               return -errno.EISDIR
+                       if parts[1] in self.getMachines():
                                return self.getacl(parts[1])[offset:offset+length]
                                return self.getacl(parts[1])[offset:offset+length]
-                       if parts[0] == 'conf.d':
-                               return self.getconf(parts[1])[offset:offset+length]
                return -errno.ENOENT
        
        def readlink(self, path):
                return -errno.ENOENT
        
        def readlink(self, path):