@fab.parallel
def build_striped_drives(devices, mount_point='/mnt/striped', filesystem='ext4', chunk_size=64, md_device='/dev/md/striped'):
    """Build a striped array of drives with mdadm

    devices - a list of device names to include in the array
            - altenatively, a string delimitted with semicolons for use on the command line:

        fab -f fab_cassandra.py build_striped_drives:'/dev/sdb1;/dev/sdc1;/dev/sdd1;/dev/sde1;/dev/sdf1;/dev/sdg1;/dev/sdh1',/mnt/striped
    """
    with fab.settings(user='root'):
        if isinstance(devices, basestring):
            devices = devices.split(";")

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

        # Stop any existing array:
        fab.run('mdadm --stop {md_device}'.format(**locals()),quiet=True)

        # Create new array:
        fab.run('mdadm --create {md_device} -R --verbose --level=0 --metadata=1.2 --chunk={chunk_size} --raid-devices={num} {devices}'.format(
            md_device=md_device, num=len(devices), chunk_size=chunk_size, devices=" ".join(devices)))

        # Format it:
        fab.run('mkfs -t {filesystem} {md_device}'.format(**locals()))

        # Mount it:
        fab.run('mkdir -p {mount_point} && mount {md_device} {mount_point}'.format(**locals()))

        fab.run('chmod 777 {mount_point}'.format(**locals()))
dataset/ETHPy150Open datastax/cstar_perf/tool/cstar_perf/tool/fab_common.py/build_striped_drives/original