Exemplo n.º 1
0
def umount(device):
    if not is_mounted(device):
        return
    cmd = ['umount', device]
    try:
        check_call(cmd, shell=False)
    except:
        raise Error("Cannot umount %s" % device)
Exemplo n.º 2
0
def write(volume, volumesize):
    d_id = vlmc.map_volume(name=volume)
    device = DEVICE_PREFIX + str(d_id)
    try:
        fd = os.open(device, os.O_WRONLY)
        os.lseek(fd, (volumesize * 1024 * 1024) + 1, os.SEEK_SET)
        os.write(fd, "This should not succeed")
        print("wtf")
    except OSError, (err, reason):
        if err != errno.EINVAL:
            raise Error("Cannot write to device %s : %s" % (device, reason))
Exemplo n.º 3
0
def read_data(volume, mountdir, randomfiles):
    d_id = vlmc.map_volume(name=volume)
    device = DEVICE_PREFIX + str(d_id)
    try:
        mount(device, mountdir)
        for rf in randomfiles:
            print "reading " + rf[0]
            f = open(os.path.join(mountdir, rf[0]), 'r')
            data = f.read()
            f.close()
            if data != rf[1]:
                raise Error("Data mismatch %s" % rf[0])
    finally:
        umount(device)
        vlmc.unmap_volume(name=device)
Exemplo n.º 4
0
def mount(device, directory):
    cmd = ['mount', device, directory]
    try:
        check_call(cmd, shell=False)
    except:
        raise Error("Cannot mount %s to %s" % (device, directory))