Example #1
0
class FcombineDaemon:

    def main(self):
        # initialize the ramdisk where all the serverlinks will be mounted
        self.init_ramdisks()
        self.init_dirimporter()
        self.init_xml_rpc_server()

    def init_xml_rpc_server(self):
        self.xml_rpc_thread = XMLRPCThread()

        self.user_dao = UserDAO()
        self.server_dao = ServerDAO()

        # expose the demand mounter to the XML RPC server
        self.xml_rpc_thread.server.add_object(self.user_dao)
        self.xml_rpc_thread.server.add_object(self.server_dao)

        # start the XML RPC server
        self.xml_rpc_thread.start()

    def init_ramdisks(self):
        # create ramdisk for server mounts
        self.create_ramdisk(xsftp.common.constants.SERVER_DIR, \
                xsftp.common.constants.SERVER_RAMDISK_SIZE_MB)

        # create ramdisk for the source home directory (i.e. Bind mount points)
        # the automounter will create something that looks like a bind
        # mount from HOMEDIR_SOURCE to /home, but it allows us to intercept
        # operations
        self.create_ramdisk(xsftp.common.constants.HOMEDIR_SOURCE, \
                xsftp.common.constants.HOME_RAMDISK_SIZE_MB)

    def init_dirimporter(self):
        # start the worker thread that periodically imports user details from
        # any defined Directory Servers
        self.dir_importer_thread = DirImporterThread()
        self.dir_importer_thread.start()

    def create_ramdisk(self, mountpoint, size):
        # ensure serverdir exists
        if not os.path.exists(mountpoint):
            os.makedirs(mountpoint)

        # see if it's already mounted
        if mountutil.is_mounted(mountpoint) == True:
            log(2, "%s was already mounted, unmounting")
            mountutil.unmount(mountpoint)

        # create the ramdisk and mount it at SERVERDIR
        mount_cmd = ["mount", "-t", "tmpfs", "-o", \
                "size=" + str(size) + "M", "tmpfs", mountpoint]

        popenutil.quick_popen(mount_cmd)
Example #2
0
 def init_dirimporter(self):
     # start the worker thread that periodically imports user details from
     # any defined Directory Servers
     self.dir_importer_thread = DirImporterThread()
     self.dir_importer_thread.start()