#! /usr/bin/env python
import isi.hw.hal as hal
import isi.sys.disk as disk
import isi.sys.geom as geom

mesh = geom.Mesh()

def main():
    # XXX FIXME Vault drive == boot drive for now, this will change
    # eventually and we need a new API for this
    devices = ["ada0"]
    dev = devices[0]
    d_provider = mesh.disk_provider(dev)
    partition_g = d_provider.partition_geom
    # No partitions on disk, wipe and create GPT table
    # If we have more than one partition and that's not
    # the PMP partition, also wipe it.
    if partition_g is None or len(partition_g.providers) > 0:
        disk.wipe_disk_provider(d_provider)
        mesh.refresh()
        disk.fix_gpt(d_provider)
        partition_g = d_provider.partition_geom
    # XXX PSI PIPELINE - This should likely be a configurable
    size = 20 * (1024*1024*1024)
    disk.make_partition(partition_g, 'isilon-pmp',
        geom.GPT_ENT_TYPE_ISILON_PMP, size)

if __name__ == '__main__':
    main()
