Example #1
0
def partition_table_show(ns, disk, human_friendly):
    """
    Print extended information about the partition table on given disk.

    :type disk: LMIInstance/CIM_StorageExtent or string
    :param disk: Device with partition table to show.
    """
    disk = common.str2device(ns, disk)
    yield ("Data Type", "Partition Table")

    table = disk.first_associator(AssocClass="CIM_InstalledPartitionTable")
    cls = ns.LMI_DiskPartitionConfigurationCapabilities
    if table.PartitionStyle == cls.PartitionStyleValues.MBR:
        yield ("Partition Table Type", "MS-DOS")
    else:
        yield ("Partition Table Type",
               cls.PartitionStyleValues.value_name(table.PartitionStyle))
    yield ("Partition Table Size (in blocks)", table.PartitionTableSize)
    yield ("Largest Free Space",
           common.size2str(partition.get_largest_partition_size(ns, disk),
                           human_friendly))

    parts = partition.get_disk_partitions(ns, disk)
    partnames = [part.Name for part in parts]
    yield ("Partitions", " ".join(partnames))
    def execute(self, ns, devices=None):
        """
        Implementation of 'partition-table list' command.
        """
        for (device, _table) in partition.get_partition_tables(ns, devices):
            largest_size = partition.get_largest_partition_size(ns, device)
            largest_size = size2str(largest_size,
                    self.app.config.human_friendly)

            yield (device.DeviceID,
                    device.Name,
                    device.ElementName,
                    largest_size
                    )
    def execute(self, ns, devices=None):
        """
        Implementation of 'partition-table list' command.
        """
        cls = ns.LMI_DiskPartitionConfigurationCapabilities
        for (device, table) in partition.get_partition_tables(ns, devices):
            LOG().debug("Examining %s", device.Name)
            largest_size = partition.get_largest_partition_size(ns, device)
            largest_size = size2str(largest_size,
                                    self.app.config.human_friendly)

            if table.PartitionStyle == cls.PartitionStyleValues.MBR:
                table_type = "MS-DOS"
            else:
                table_type = cls.PartitionStyleValues.value_name(
                    table.PartitionStyle)

            yield (device.Name, table_type, largest_size)
    def execute(self, ns, devices=None):
        """
        Implementation of 'partition-table list' command.
        """
        cls = ns.LMI_DiskPartitionConfigurationCapabilities
        for (device, table) in partition.get_partition_tables(ns, devices):
            LOG().debug("Examining %s", device.Name)
            largest_size = partition.get_largest_partition_size(ns, device)
            largest_size = size2str(largest_size,
                    self.app.config.human_friendly)

            if table.PartitionStyle == cls.PartitionStyleValues.MBR:
                table_type = "MS-DOS"
            else:
                table_type = cls.PartitionStyleValues.value_name(
                        table.PartitionStyle)

            yield (device.Name, table_type, largest_size)
Example #5
0
def partition_table_show(ns, disk, human_friendly):
    """
    Print extended information about the partition table on given disk.

    :type disk: LMIInstance/CIM_StorageExtent or string
    :param disk: Device with partition table to show.
    """
    disk = common.str2device(ns, disk)
    yield ("Data Type", "Partition Table")

    table = disk.first_associator(AssocClass="CIM_InstalledPartitionTable")
    cls = ns.LMI_DiskPartitionConfigurationCapabilities
    if table.PartitionStyle == cls.PartitionStyleValues.MBR:
        yield ("Partition Table Type", "MS-DOS")
    else:
        yield ("Partition Table Type", cls.PartitionStyleValues.value_name(table.PartitionStyle))
    yield ("Partition Table Size (in blocks)", table.PartitionTableSize)
    yield ("Largest Free Space", common.size2str(partition.get_largest_partition_size(ns, disk), human_friendly))

    parts = partition.get_disk_partitions(ns, disk)
    partnames = [part.Name for part in parts]
    yield ("Partitions", " ".join(partnames))