@fab.parallel
def build_jbod_drives(device_mounts, md_device='/dev/md/striped', filesystem='ext4'):
    """Build a jbod configuration for drives

    device_mounts - a dictionary of device names -> mountpoints. Alternatively, can be a string representation.
        fab -f fab_cassandra.py build_jbod_drives:"{'/dev/sdb1':'/mnt/d1'\,'/dev/sdc1':'/mnt/d2'\,'/dev/sdd1':'/mnt/d3'\,'/dev/sde1':'/mnt/d4'\,'/dev/sdf1':'/mnt/d5'\,'/dev/sdg1':'/mnt/d6'\,'/dev/sdh1':'/mnt/d7'}"
    md_device - The mdadm striped device that may need to be destoyed first.

    Formats the devices and mounts the filesystems.
    """
    with fab.settings(user='root'):
        if isinstance(device_mounts, basestring):
            device_mounts = eval(device_mounts)

        # Destroy the mdadm striped device:
        fab.run('umount {md_device} && mdadm --stop {md_device}'.format(**locals()), quiet=True)

        mounted = fab.run('mount',quiet=True)
        for device in [d for d in device_mounts.keys() if d in mounted]:
            # Unmount devices:
            fab.run('umount -f {device}'.format(**locals()))

        # Format in parallel :
        fab.run('echo -e "{devices}" | xargs -n 1 -P {num} -iXX mkfs -t {filesystem} XX'.format(devices="\n".join(device_mounts.keys()), filesystem=filesystem, num=len(device_mounts)))

        for device,mountpoint in device_mounts.items():
            # Mount:
            fab.run('mount {device} {mountpoint}'.format(**locals()))
            fab.run('chmod 777 {mountpoint}'.format(**locals()))
dataset/ETHPy150Open datastax/cstar_perf/tool/cstar_perf/tool/fab_common.py/build_jbod_drives/original