예제 #1
0
    def prepare(self, conn):
        mnt_point = tempfile.mkdtemp(dir='/tmp')
        export_path = "%s:%s" % (
            self.poolArgs['source']['host'], self.poolArgs['source']['path'])
        mount_cmd = ["mount", "-o", 'soft,timeo=100,retrans=3,retry=0',
                     export_path, mnt_point]
        umount_cmd = ["umount", "-f", export_path]
        mounted = False
        # Due to an NFS bug (See Red Hat BZ 1023059), NFSv4 exports may take
        # 10-15 seconds to mount the first time.
        cmd_timeout = 15

        with RollbackContext() as rollback:
            rollback.prependDefer(os.rmdir, mnt_point)
            try:
                run_command(mount_cmd, cmd_timeout)
                rollback.prependDefer(run_command, umount_cmd, cmd_timeout)
            except TimeoutExpired:
                raise InvalidParameter("KCHPOOL0012E", {'path': export_path})
            with open("/proc/mounts", "rb") as f:
                rawMounts = f.read()
            output_items = ['dev_path', 'mnt_point', 'type']
            mounts = parse_cmd_output(rawMounts, output_items)
            for item in mounts:
                if 'dev_path' in item and item['dev_path'] == export_path:
                    mounted = True

            if not mounted:
                raise InvalidParameter("KCHPOOL0013E", {'path': export_path})
예제 #2
0
    def prepare(self, conn):
        mnt_point = tempfile.mkdtemp(dir='/tmp')
        export_path = "%s:%s" % (self.poolArgs['source']['host'],
                                 self.poolArgs['source']['path'])
        mount_cmd = [
            "mount", "-o", 'soft,timeo=100,retrans=3,retry=0', export_path,
            mnt_point
        ]
        umount_cmd = ["umount", "-f", export_path]
        mounted = False
        # 2 seconds looks like a reasonable time to wait for a refresh
        # in the UI and enough time to verify that the NFS server
        # is down.
        cmd_timeout = 2

        with RollbackContext() as rollback:
            rollback.prependDefer(os.rmdir, mnt_point)
            try:
                run_command(mount_cmd, cmd_timeout)
                rollback.prependDefer(run_command, umount_cmd, cmd_timeout)
            except TimeoutExpired:
                raise InvalidParameter("KCHPOOL0012E", {'path': export_path})
            with open("/proc/mounts", "rb") as f:
                rawMounts = f.read()
            output_items = ['dev_path', 'mnt_point', 'type']
            mounts = parse_cmd_output(rawMounts, output_items)
            for item in mounts:
                if 'dev_path' in item and item['dev_path'] == export_path:
                    mounted = True

            if not mounted:
                raise InvalidParameter("KCHPOOL0013E", {'path': export_path})
예제 #3
0
    def prepare(self, conn):
        mnt_point = tempfile.mkdtemp(dir='/tmp')
        export_path = "%s:%s" % (self.poolArgs['source']['host'],
                                 self.poolArgs['source']['path'])
        mount_cmd = [
            "mount", "-o", 'soft,timeo=100,retrans=3,retry=0', export_path,
            mnt_point
        ]
        umount_cmd = ["umount", "-f", export_path]
        mounted = False
        # Due to an NFS bug (See Red Hat BZ 1023059), NFSv4 exports may take
        # 10-15 seconds to mount the first time.
        cmd_timeout = 15

        with RollbackContext() as rollback:
            rollback.prependDefer(os.rmdir, mnt_point)
            try:
                run_command(mount_cmd, cmd_timeout)
                rollback.prependDefer(run_command, umount_cmd, cmd_timeout)
            except TimeoutExpired:
                raise InvalidParameter("KCHPOOL0012E", {'path': export_path})
            with open("/proc/mounts", "rb") as f:
                rawMounts = f.read()
            output_items = ['dev_path', 'mnt_point', 'type']
            mounts = parse_cmd_output(rawMounts, output_items)
            for item in mounts:
                if 'dev_path' in item and item['dev_path'] == export_path:
                    mounted = True

            if not mounted:
                raise InvalidParameter("KCHPOOL0013E", {'path': export_path})
예제 #4
0
    def prepare(self, conn):
        mnt_point = tempfile.mkdtemp(dir='/tmp')
        export_path = "%s:%s" % (
            self.poolArgs['source']['host'], self.poolArgs['source']['path'])
        mount_cmd = ["mount", "-o", 'soft,timeo=100,retrans=3,retry=0',
                     export_path, mnt_point]
        umount_cmd = ["umount", "-f", export_path]
        mounted = False
        # 2 seconds looks like a reasonable time to wait for a refresh
        # in the UI and enough time to verify that the NFS server
        # is down.
        cmd_timeout = 2

        with RollbackContext() as rollback:
            rollback.prependDefer(os.rmdir, mnt_point)
            try:
                run_command(mount_cmd, cmd_timeout)
                rollback.prependDefer(run_command, umount_cmd, cmd_timeout)
            except TimeoutExpired:
                raise InvalidParameter("KCHPOOL0012E", {'path': export_path})
            with open("/proc/mounts", "rb") as f:
                rawMounts = f.read()
            output_items = ['dev_path', 'mnt_point', 'type']
            mounts = parse_cmd_output(rawMounts, output_items)
            for item in mounts:
                if 'dev_path' in item and item['dev_path'] == export_path:
                    mounted = True

            if not mounted:
                raise InvalidParameter("KCHPOOL0013E", {'path': export_path})