Example #1
0
def main():
    env = ReadEnv()
    if env is None:
        sys.stderr.write("Wrong environment. Aborting...\n")
        return 1

    loadrc(None)

    os.umask(config['UMASK'])

    actions = {
        'create': create,
        'snapshot': snapshot,
        'attach': attach,
        'detach': detach,
        'grow': grow,
        'remove': remove,
        'verify': verify,
        'setinfo': setinfo,
    }

    try:
        action_name = os.path.basename(sys.argv[0])
        sys.stderr.write("Action is %s\n" % action_name)
        action = actions[action_name]
        return action(env)
    except KeyError:
        sys.stderr.write("Action '%s' not supported\n" % action_name)
        return 1
    except Error as e:
        sys.stderr.write("Archipelago error: %s\n" % e)
        return 1
Example #2
0
            if data != rf[1]:
                raise Error("Data mismatch %s" % rf[0])
    finally:
        umount(device)
        vlmc.unmap_volume(name=device)


def snapshot(volume):
    vlmc.snapshot(name=volume)


if __name__ == '__main__':

    # Archipelago needs umask 007
    os.umask(7)
    loadrc(None)
    peers = construct_peers()
    tmpvolume = gettempname()
    mntdir = '/mnt/mountpoint'
    RANDOMSIZE = 20 * 1024 * 1024

    test_create(tmpvolume, volumesize=10240)
    try:
        write(tmpvolume, 10240)
        mkfs_and_mount(tmpvolume, mntdir)

        rf = [getrandomfile(RANDOMSIZE)]
        write_data(tmpvolume, mntdir, rf)
        archipelago.restart(user=True)
        read_data(tmpvolume, mntdir, rf)
Example #3
0
            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 snapshot(volume):
    vlmc.snapshot(name=volume)

if __name__ == '__main__':

    # Archipelago needs umask 007
    os.umask(7)
    loadrc(None)
    peers = construct_peers()
    tmpvolume=gettempname()
    mntdir = '/mnt/mountpoint'
    RANDOMSIZE=20*1024*1024

    test_create(tmpvolume, volumesize=10240)
    try:
        write(tmpvolume, 10240)
        mkfs_and_mount(tmpvolume, mntdir)

        rf = [getrandomfile(RANDOMSIZE)]
        write_data(tmpvolume, mntdir, rf)
        archipelago.restart(user=True)
        read_data(tmpvolume, mntdir, rf)