Example #1
0
    def mount_server(self, server_name):
        log(6, "mount_server")

        # check to see if the server is already mounted by checking the dict
        if server_name in self.mounted_servers:
            # we're already SLAM mounted, so nothing more to do
            return

        # We're not mounted, so we need to get the server object from the daemon
        server = None
        try:
            server = self.xml_rpc_server.get_server_by_name(server_name)
        except XMLRPCClient.dex("xsftp.common.models.Server.DoesNotExist"):
            log(2, "Cannot mount server %s, don't know about it!" %
                    (server_name))
            return

        server.mount_point = os.path.join( \
                self.server_root_mount_point, server.name)

        if os.path.exists(server.mount_point) == False:
            os.makedirs(server.mount_point)

        if mountutil.is_mounted(server.mount_point) == True:
            log(3, "Server already mounted: %s" % server.mount_point)
        else:
            # determine the type of mounter needed
            mounter_class = self.mounter_factory.get_mounter_class( \
                    server.type)
            mounter = mounter_class()
            mounter.mount(server)

        self.mounted_servers[server_name] = server
        
        return server
Example #2
0
    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 #3
0
    def mount_bmp(self, username, server):
        #_name, server_mount_point):
        log(6, "mount_bmp")
        bind_mount_point = os.path.join(self.home_source, \
                username, self.BMP_DIR, server.server_name)

        if mountutil.is_mounted(bind_mount_point) == True:
            log(3, "BMP already mounted: %s" % bind_mount_point)
            return

        cmd = ["mount", "-o", "bind", server.mount_point, \
              bind_mount_point]

        popenutil.quick_popen(cmd)

        server.add_bind_mount(username, bind_mount_point)