Exemple #1
0
def mkfs_and_mount(volume, mountdir):
    d_id = vlmc.map_volume(name=volume)
    device = DEVICE_PREFIX + str(d_id)

    cmd = ['mkfs.ext3', device]
    check_call(cmd, shell=False)
    try:
        mount(device, mountdir)
        umount(device)
    finally:
        vlmc.unmap_volume(name=device)
Exemple #2
0
def mkfs_and_mount(volume, mountdir):
    d_id=vlmc.map_volume(name=volume)
    device = DEVICE_PREFIX + str(d_id)

    cmd = ['mkfs.ext3', device]
    check_call(cmd, shell=False)
    try:
        mount(device, mountdir)
        umount(device)
    finally:
        vlmc.unmap_volume(name=device)
Exemple #3
0
def write_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 "writing " + rf[0]
            f = open(os.path.join(mountdir, rf[0]), 'w')
            f.write(rf[1])
            f.close()
    finally:
        umount(device)
        vlmc.unmap_volume(name=device)
Exemple #4
0
def write_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 "writing " + rf[0]
            f = open(os.path.join(mountdir, rf[0]), 'w')
            f.write(rf[1])
            f.close()
    finally:
        umount(device)
        vlmc.unmap_volume(name=device)
Exemple #5
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)
Exemple #6
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)
def detach(env):
    """Unmap a vlmc device from the Image it is mapped to

    This function unmaps an vlmc device from the Image it is mapped to.
    It is idempotent if the mapping doesn't exist at all.

    """
    name = env.get("name")

    #try:
    # Check if the mapping already exists
    d_id = vlmc.is_mapped(name)
    if d_id is not None:
        # The mapping exists. Unmap the vlmc device.
        vlmc.unmap_volume(name=str(DEVICE_PREFIX + str(d_id)))
    #assert(vlmc.is_mapped(name) == None)
    return 0
def detach(env):
    """Unmap a vlmc device from the Image it is mapped to

    This function unmaps an vlmc device from the Image it is mapped to.
    It is idempotent if the mapping doesn't exist at all.

    """
    name = env.get("name")

    #try:
    # Check if the mapping already exists
    d_id = vlmc.is_mapped(name)
    if d_id:
        # The mapping exists. Unmap the vlmc device.
        vlmc.unmap_volume(name=str(DEVICE_PREFIX + str(d_id)))
    #assert(vlmc.is_mapped(name) == None)
    return 0
Exemple #9
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))
    finally:
        if fd:
            os.close(fd)
        vlmc.unmap_volume(name=device)


def mkfs_and_mount(volume, mountdir):
    d_id = vlmc.map_volume(name=volume)
    device = DEVICE_PREFIX + str(d_id)

    cmd = ['mkfs.ext3', device]
    check_call(cmd, shell=False)
    try:
        mount(device, mountdir)
        umount(device)
    finally:
        vlmc.unmap_volume(name=device)

Exemple #10
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))
    finally:
        if fd:
            os.close(fd)
        vlmc.unmap_volume(name=device)


def mkfs_and_mount(volume, mountdir):
    d_id=vlmc.map_volume(name=volume)
    device = DEVICE_PREFIX + str(d_id)

    cmd = ['mkfs.ext3', device]
    check_call(cmd, shell=False)
    try:
        mount(device, mountdir)
        umount(device)
    finally:
        vlmc.unmap_volume(name=device)