Changeset 519


Ignore:
Timestamp:
May 10, 2008, 8:46:43 PM (16 years ago)
Author:
price
Message:

remconffs: cat conf-files together

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/sipb-xen-remote-server/files/usr/sbin/sipb-xen-remconffs

    r518 r519  
    105105                                    ''])
    106106               
    107         def getconf(self, machine_name):
    108                 """Build the command file for a machine
    109                 """
    110                 return ("control %s /usr/sbin/sipb-xen-remote-proxy-control"
    111                         " /etc/remctl/sipb-xen-auto/acl/%s\n"
    112                         % (machine_name, machine_name))
    113                
    114         def getfile(self, dir, machine_name):
    115                 """Build the ACL or command file for a machine
    116                 """
    117                 if dir == 'acl':    return self.getacl(machine_name)
    118                 if dir == 'conf.d': return self.getconf(machine_name)
    119                 raise "this shouldn't happen"
     107        def getconf(self):
     108                """Build the master conf file, with all machines
     109                """
     110                return '\n'.join("control %s /usr/sbin/sipb-xen-remote-proxy-control"
     111                                 " /etc/remctl/remconffs/acl/%s"
     112                                 % (machine_name, machine_name)
     113                                 for machine_name in self.getMachines())+'\n'
    120114       
    121115        def userToPrinc(self, user):
     
    156150                        st.st_nlink = 2
    157151                elif depth == 1:
    158                         if parts[0] not in ('acl', 'conf.d'):
    159                                 return -errno.ENOENT
    160                         st.st_mode = stat.S_IFDIR | 0755
    161                         st.st_nlink = 2
     152                        if parts[0] == 'acl':
     153                                st.st_mode = stat.S_IFDIR | 0755
     154                                st.st_nlink = 2
     155                        elif parts[0] == 'conf':
     156                                st.st_mode = stat.S_IFREG | 0444
     157                                st.st_nlink = 1
     158                                st.st_size = len(self.getconf())
     159                        else:
     160                                return -errno.ENOENT
    162161                elif depth == 2:
    163                         if parts[0] not in ('acl', 'conf.d'):
     162                        if parts[0] != 'acl':
    164163                                return -errno.ENOENT
    165164                        if parts[1] not in self.getMachines():
     
    167166                        st.st_mode = stat.S_IFREG | 0444
    168167                        st.st_nlink = 1
    169                         st.st_size = len(self.getfile(parts[0], parts[1]))
     168                        st.st_size = len(self.getacl(parts[1]))
    170169
    171170                return st.toTuple()
     
    191190
    192191                if depth == 0:
    193                         contents = ('acl', 'conf.d')
     192                        contents = ('acl', 'conf')
    194193                elif depth == 1:
    195                         if parts[0] in ('acl', 'conf.d'):
     194                        if parts[0] == 'acl':
    196195                                contents = self.getMachines()
    197196                        else:
     
    212211                parts, depth = parse(path)
    213212               
    214                 # If the depth is not 2, then either it's a directory or the file
    215                 # doesn't exist
    216                 # (realistically this doesn't appear to ever happen)
    217                 if getDepth(path) != 2:
    218                         return -errno.ENOENT
    219                 elif parts[1] in self.getMachines():
    220                         if parts[0] == 'acl':
     213                if depth == 0:
     214                        return -errno.EISDIR
     215                elif parts[0] == 'conf':
     216                        return self.getconf()[offset:offset+length]
     217                elif parts[0] == 'acl':
     218                        if depth == 1:
     219                                return -errno.EISDIR
     220                        if parts[1] in self.getMachines():
    221221                                return self.getacl(parts[1])[offset:offset+length]
    222                         if parts[0] == 'conf.d':
    223                                 return self.getconf(parts[1])[offset:offset+length]
    224222                return -errno.ENOENT
    225223       
Note: See TracChangeset for help on using the changeset viewer.