示例#1
0
def newDisk(device):
    """Return a Disk object for this Device. Read the partition table off
       a device (if one is found)."""
    from _ped import disk_new

    peddisk = disk_new(device.getPedDevice())
    return Disk(PedDisk=peddisk)
示例#2
0
def freshDisk(device, ty):
    """Return a Disk object for this Device and using this DiskType.
       The type should be a member of the parted.diskType hash,
       either a key or a value.

       The new label is not written to disk until commitToDevice()
       is called on the Disk."""
    from _ped import disk_new_fresh, DiskType

    if isinstance(ty, string_types):
        ty = diskType[ty]
    elif not isinstance(ty, DiskType):
        raise TypeError("type must be a key or value in parted.diskType", ty)

    peddisk = disk_new_fresh(device.getPedDevice(), ty)
    return Disk(PedDisk=peddisk)