Exemple #1
0
def fs_show(ns, fmt, human_friendly):
    """
    Display description of filesystem on the device.

    :type fmt: LMIInstance/CIM_LocalFileSystem or string
    :param fmt: Filesystem to show.
    """
    yield ("Filesystem", fmt.FileSystemType)
    if "UUID" in fmt.properties() and fmt.UUID:
        yield ("UUID", fmt.UUID)
    cls = ns.LMI_LocalFileSystem
    yield ("Persistence",
           cls.PersistenceTypeValues.value_name(fmt.PersistenceType))

    size = "Unknown (not mounted)"
    if fmt.FileSystemSize:
        size = common.size2str(fmt.FileSystemSize, human_friendly)
    else:
        size = "Unknown (not mounted?)"
    yield ("Total space on filesystem", size)

    if fmt.AvailableSpace:
        free = common.size2str(fmt.AvailableSpace, human_friendly)
    else:
        free = "Unknown (not mounted?)"
    yield ("Free space on filesystem", free)
Exemple #2
0
def fs_show(ns, fmt, human_friendly):
    """
    Display description of filesystem on the device.

    :type fmt: LMIInstance/CIM_LocalFileSystem or string
    :param fmt: Filesystem to show.
    """
    yield("Filesystem", fmt.FileSystemType)
    if "UUID" in fmt.properties() and fmt.UUID:
        yield("UUID", fmt.UUID)
    cls = ns.LMI_LocalFileSystem
    yield("Persistence", cls.PersistenceTypeValues.value_name(
            fmt.PersistenceType))

    size = "Unknown (not mounted)"
    if fmt.FileSystemSize:
        size = common.size2str(fmt.FileSystemSize, human_friendly)
    else:
        size = "Unknown (not mounted?)"
    yield("Total space on filesystem", size)

    if fmt.AvailableSpace:
        free = common.size2str(fmt.AvailableSpace, human_friendly)
    else:
        free = "Unknown (not mounted?)"
    yield("Free space on filesystem", free)
Exemple #3
0
def vg_show(ns, vg, human_friendly):
    """
    Print extended information about the Volume Group.

    :type vg: LMIInstance/LMI_VGStoragePool or string
    :param vg: Volume Group to show.
    """
    yield ("Type", "Volume Group")
    vg = common.str2vg(ns, vg)
    yield ("InstanceID", vg.InstanceID)
    yield ("ElementName", vg.ElementName)
    yield ("Extent Size", common.size2str(vg.ExtentSize, human_friendly))
    yield ("Total Size", common.size2str(vg.TotalManagedSpace, human_friendly))
    yield ("Total Extents", vg.TotalExtents)
    yield ("Free Space", common.size2str(vg.RemainingManagedSpace, human_friendly))
    yield ("Free Extents", vg.RemainingExtents)

    pvs = lvm.get_vg_pvs(ns, vg)
    pvnames = [pv.Name for pv in pvs]
    yield ("Physical Volumes", " ".join(pvnames))

    lvs = lvm.get_vg_lvs(ns, vg)
    lvnames = [lv.Name for lv in lvs]
    yield ("Logical Volumes", " ".join(lvnames))

    tps = lvm.get_vg_tps(ns, vg)
    tpnames = [tp.Name for tp in tps]
    yield ("Thin Pools", " ".join(tpnames))
Exemple #4
0
def vg_show(ns, vg, human_friendly):
    """
    Print extended information about the Volume Group.

    :type vg: LMIInstance/LMI_VGStoragePool or string
    :param vg: Volume Group to show.
    """
    yield ("Type", "Volume Group")
    vg = common.str2vg(ns, vg)
    yield ("InstanceID", vg.InstanceID)
    yield ("ElementName", vg.ElementName)
    yield ("Extent Size", common.size2str(vg.ExtentSize, human_friendly))
    yield ("Total Size", common.size2str(vg.TotalManagedSpace, human_friendly))
    yield ("Total Extents", vg.TotalExtents)
    yield ("Free Space",
           common.size2str(vg.RemainingManagedSpace, human_friendly))
    yield ("Free Extents", vg.RemainingExtents)

    pvs = lvm.get_vg_pvs(ns, vg)
    pvnames = [pv.Name for pv in pvs]
    yield ("Physical Volumes", " ".join(pvnames))

    lvs = lvm.get_vg_lvs(ns, vg)
    lvnames = [lv.Name for lv in lvs]
    yield ("Logical Volumes", " ".join(lvnames))

    tps = lvm.get_vg_tps(ns, vg)
    tpnames = [tp.Name for tp in tps]
    yield ("Thin Pools", " ".join(tpnames))
Exemple #5
0
 def execute(self, ns):
     """
     Implementation of 'vg list' command.
     """
     for vg in lvm.get_vgs(ns):
         extent_size = size2str(vg.ExtentSize, self.app.config.human_friendly)
         total_space = size2str(vg.TotalManagedSpace, self.app.config.human_friendly)
         remaining_space = size2str(vg.RemainingManagedSpace, self.app.config.human_friendly)
         yield (vg.ElementName, extent_size, total_space, remaining_space)
Exemple #6
0
 def execute(self, ns):
     """
     Implementation of 'vg list' command.
     """
     for vg in lvm.get_vgs(ns):
         extent_size = size2str(vg.ExtentSize,
                                self.app.config.human_friendly)
         total_space = size2str(vg.TotalManagedSpace,
                                self.app.config.human_friendly)
         remaining_space = size2str(vg.RemainingManagedSpace,
                                    self.app.config.human_friendly)
         yield (vg.ElementName, extent_size, total_space, remaining_space)
Exemple #7
0
def device_show_device(ns, device, human_friendly):
    """
    Print basic information about storage device, common to all device types.

    :type device: LMIInstance/CIM_StorageExtent or string
    :param device: Device to show.
    """
    device = common.str2device(ns, device)

    yield ("DeviceID", device.DeviceID)
    yield ("Name", device.Name)
    yield ("ElementName", device.ElementName)
    yield ("Total Size", common.size2str(device.NumberOfBlocks * device.BlockSize, human_friendly))
    yield ("Block Size", common.size2str(device.BlockSize, human_friendly))
Exemple #8
0
def device_show_device(ns, device, human_friendly):
    """
    Print basic information about storage device, common to all device types.

    :type device: LMIInstance/CIM_StorageExtent or string
    :param device: Device to show.
    """
    device = common.str2device(ns, device)

    yield("DeviceID", device.DeviceID)
    yield("Name", device.Name)
    yield("ElementName", device.ElementName)
    yield("Total Size", common.size2str(
            device.NumberOfBlocks * device.BlockSize, human_friendly))
    yield("Block Size", common.size2str(device.BlockSize, human_friendly))
def get_pool_info(_ns, pool, human_friendly):
    """
    Return detailed information of the Volume Group to show.
    """
    size = size2str(pool.TotalManagedSpace, human_friendly)
    return (pool.InstanceID, pool.ElementName, pool.ElementName, size,
            "volume group (LVM)")
Exemple #10
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))
Exemple #11
0
def partition_show(ns, part, human_friendly):
    """
    Print extended information about the partition.

    :type part: LMIInstance/CIM_GenericDiskPartition or string
    :param part: Partition to show.
    """
    part = common.str2device(ns, part)
    yield ("Type", "Partition")
    for line in device_show_device(ns, part, human_friendly):
        yield line

    if "PartitionType" in part.properties():
        cls = ns.LMI_DiskPartition
        if part.PartitionType == cls.PartitionTypeValues.Primary:
            ptype = "primary"
        elif part.PartitionType == cls.PartitionTypeValues.Extended:
            ptype = "extended"
        elif part.PartitionType == cls.PartitionTypeValues.Logical:
            ptype = "logical"
        else:
            ptype = "unknown"
    else:
        ptype = "N/A"
    yield ("Partition Type", ptype)

    basedon = part.first_reference(ResultClass="CIM_BasedOn", Role="Dependent")
    yield ("Starting sector", basedon.StartingAddress)
    yield ("Ending sector", basedon.EndingAddress)

    disk = partition.get_partition_disk(ns, part)
    yield ("Sector Size", common.size2str(disk.BlockSize, human_friendly))
    yield ("Disk", disk.Name)
    for line in device_show_data(ns, part, human_friendly):
        yield line
Exemple #12
0
def partition_show(ns, part, human_friendly):
    """
    Print extended information about the partition.

    :type part: LMIInstance/CIM_GenericDiskPartition or string
    :param part: Partition to show.
    """
    part = common.str2device(ns, part)
    yield ("Type", "Partition")
    for line in device_show_device(ns, part, human_friendly):
        yield line

    if "PartitionType" in part.properties():
        cls = ns.LMI_DiskPartition
        if part.PartitionType == cls.PartitionTypeValues.Primary:
            ptype = "primary"
        elif part.PartitionType == cls.PartitionTypeValues.Extended:
            ptype = "extended"
        elif part.PartitionType == cls.PartitionTypeValues.Logical:
            ptype = "logical"
        else:
            ptype = "unknown"
    else:
        ptype = "N/A"
    yield ("Partition Type", ptype)

    basedon = part.first_reference(ResultClass="CIM_BasedOn", Role="Dependent")
    yield ("Starting sector", basedon.StartingAddress)
    yield ("Ending sector", basedon.EndingAddress)

    disk = partition.get_partition_disk(ns, part)
    yield ("Sector Size", common.size2str(disk.BlockSize, human_friendly))
    yield ("Disk", disk.Name)
    for line in device_show_data(ns, part, human_friendly):
        yield line
Exemple #13
0
 def execute(self, ns, vgs=None):
     """
     Implementation of 'lv list' command.
     """
     for lv in lvm.get_lvs(ns, vgs):
         size = size2str(lv.NumberOfBlocks * lv.BlockSize,
                         self.app.config.human_friendly)
         yield (lv.Name, size)
def get_pool_info(_ns, pool, human_friendly):
    """
    Return detailed information of the Volume Group to show.
    """
    size = size2str(pool.TotalManagedSpace, human_friendly)
    return (pool.ElementName,
            size,
            "volume group (LVM)")
Exemple #15
0
 def execute(self, ns, vgs=None):
     """
     Implementation of 'lv list' command.
     """
     for lv in lvm.get_lvs(ns, vgs):
         size = size2str(lv.NumberOfBlocks * lv.BlockSize,
                 self.app.config.human_friendly)
         yield (lv.Name, size)
Exemple #16
0
 def execute(self, ns, tps=None):
     """
     Implementation of 'thinlv list' command.
     """
     for tlv in lvm.get_tlvs(ns, tps):
         size = size2str(tlv.NumberOfBlocks * tlv.BlockSize,
                 self.app.config.human_friendly)
         tp = lvm.get_lv_vg(ns, tlv)
         yield (tlv.ElementName, tp.ElementName, size)
Exemple #17
0
def tp_show(ns, tp, human_friendly):
    yield ("Type", "Thin Pool")
    tp = common.str2vg(ns, tp)
    yield ("InstanceID", tp.InstanceID)
    yield ("ElementName", tp.ElementName)
    yield ("Extent Size", common.size2str(tp.ExtentSize, human_friendly))
    yield ("Total Size", common.size2str(tp.TotalManagedSpace, human_friendly))
    yield ("Total Extents", tp.TotalExtents)
    yield ("Free Space", common.size2str(tp.RemainingManagedSpace, human_friendly))
    yield ("Free Extents", tp.RemainingExtents)

    vgs = lvm.get_tp_vgs(ns, tp)
    vgnames = [vg.Name for vg in vgs]
    yield ("Volume Group", " ".join(vgnames))

    lvs = lvm.get_vg_lvs(ns, tp)
    lvnames = [lv.Name for lv in lvs]
    yield ("Logical Volumes", " ".join(lvnames))
Exemple #18
0
def tp_show(ns, tp, human_friendly):
    yield ("Type", "Thin Pool")
    tp = common.str2vg(ns, tp)
    yield ("InstanceID", tp.InstanceID)
    yield ("ElementName", tp.ElementName)
    yield ("Extent Size", common.size2str(tp.ExtentSize, human_friendly))
    yield ("Total Size", common.size2str(tp.TotalManagedSpace, human_friendly))
    yield ("Total Extents", tp.TotalExtents)
    yield ("Free Space",
           common.size2str(tp.RemainingManagedSpace, human_friendly))
    yield ("Free Extents", tp.RemainingExtents)

    vgs = lvm.get_tp_vgs(ns, tp)
    vgnames = [vg.Name for vg in vgs]
    yield ("Volume Group", " ".join(vgnames))

    lvs = lvm.get_vg_lvs(ns, tp)
    lvnames = [lv.Name for lv in lvs]
    yield ("Logical Volumes", " ".join(lvnames))
def get_device_info(ns, device, human_friendly):
    """
    Return detailed information of the device to show.
    """
    if device.NumberOfBlocks and device.BlockSize:
        size = size2str(device.NumberOfBlocks * device.BlockSize, human_friendly)
    else:
        size = "N/A"

    fslabel = fs.get_device_format_label(ns, device)
    return (device.Name, size, fslabel)
Exemple #20
0
 def execute(self, ns, devices=None, _all=False):
     """
     Implementation of 'fs list' command.
     """
     for fmt in fs.get_formats(ns, devices, fs.FORMAT_ALL, _all):
         name = fmt.Name
         label = fmt.ElementName
         if "FileSystemType" in fmt.properties():
             # it's CIM_LocalFileSystem
             # TODO: add filesystem size and free space
             fstype = fmt.FileSystemType
         else:
             # it must be LMI_DataFormat
             fstype = fmt.FormatTypeDescription
         size = "N/A"
         free = "N/A"
         if "FileSystemSize" in fmt.properties() and fmt.FileSystemSize:
             size = size2str(fmt.FileSystemSize, self.app.config.human_friendly)
         if "AvailableSpace" in fmt.properties() and fmt.AvailableSpace:
             free = size2str(fmt.AvailableSpace, self.app.config.human_friendly)
         yield (name, label, fstype, size, free)
Exemple #21
0
def get_device_info(ns, device, human_friendly):
    """
    Return detailed information of the device to show.
    """
    if device.NumberOfBlocks and device.BlockSize:
        size = size2str(device.NumberOfBlocks * device.BlockSize,
                        human_friendly)
    else:
        size = 'N/A'

    fslabel = fs.get_device_format_label(ns, device)
    return (device.DeviceID, device.Name, device.ElementName, size, fslabel)
    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
                    )
Exemple #23
0
 def execute(self, ns, devices=None, _all=False):
     """
     Implementation of 'fs list' command.
     """
     for fmt in fs.get_formats(ns, devices, fs.FORMAT_ALL, _all):
         name = fmt.Name
         label = fmt.ElementName
         if "FileSystemType" in fmt.properties():
             # it's CIM_LocalFileSystem
             # TODO: add filesystem size and free space
             fstype = fmt.FileSystemType
         else:
             # it must be LMI_DataFormat
             fstype = fmt.FormatTypeDescription
         size = "N/A"
         free = "N/A"
         if "FileSystemSize" in fmt.properties() and fmt.FileSystemSize:
             size = size2str(fmt.FileSystemSize,
                             self.app.config.human_friendly)
         if "AvailableSpace" in fmt.properties() and fmt.AvailableSpace:
             free = size2str(fmt.AvailableSpace,
                             self.app.config.human_friendly)
         yield (name, label, fstype, size, free)
    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)
Exemple #26
0
 def execute(self, ns, devices=None):
     """
     Implementation of 'partition list' command.
     """
     for part in partition.get_partitions(ns, devices):
         ptype = ""
         values = ns.LMI_DiskPartition.PartitionTypeValues
         if "PartitionType" in part.properties():
             if part.PartitionType == values.Primary:
                 ptype = "primary"
             elif part.PartitionType == values.Extended:
                 ptype = "extended"
             elif part.PartitionType == values.Logical:
                 ptype = "logical"
             else:
                 ptype = "unknown"
         size = size2str(part.NumberOfBlocks * part.BlockSize,
                 self.app.config.human_friendly)
         yield (part.Name, ptype, size)
Exemple #27
0
def lv_show(ns, lv, human_friendly):
    """
    Print extended information about the Logical Volume.

    :type lv: LMIInstance/LMI_LVStorageExtent or string
    :param lv: Logical Volume to show.
    """
    lv = common.str2device(ns, lv)
    yield ("Type", "Logical Volume")
    for line in device_show_device(ns, lv, human_friendly):
        yield line

    vg = lvm.get_lv_vg(ns, lv)
    yield ("Volume Group", vg.ElementName)
    yield ("Extent Size", common.size2str(vg.ExtentSize, human_friendly))
    yield ("Number of Occupied Extents", lv.BlockSize * lv.NumberOfBlocks / vg.ExtentSize)

    for line in device_show_data(ns, lv, human_friendly):
        yield line
 def execute(self, ns, devices=None):
     """
     Implementation of 'partition list' command.
     """
     for part in partition.get_partitions(ns, devices):
         ptype = ""
         values = ns.LMI_DiskPartition.PartitionTypeValues
         if "PartitionType" in part.properties():
             if part.PartitionType == values.Primary:
                 ptype = "primary"
             elif part.PartitionType == values.Extended:
                 ptype = "extended"
             elif part.PartitionType == values.Logical:
                 ptype = "logical"
             else:
                 ptype = "unknown"
         size = size2str(part.NumberOfBlocks * part.BlockSize,
                         self.app.config.human_friendly)
         yield (part.DeviceID, part.Name, part.ElementName, ptype, size)
Exemple #29
0
def lv_show(ns, lv, human_friendly):
    """
    Print extended information about the Logical Volume.

    :type lv: LMIInstance/LMI_LVStorageExtent or string
    :param lv: Logical Volume to show.
    """
    lv = common.str2device(ns, lv)
    yield ("Type", "Logical Volume")
    for line in device_show_device(ns, lv, human_friendly):
        yield line

    vg = lvm.get_lv_vg(ns, lv)
    yield ("Volume Group", vg.ElementName)
    yield ("Extent Size", common.size2str(vg.ExtentSize, human_friendly))
    yield("Number of Occupied Extents", \
            lv.BlockSize * lv.NumberOfBlocks / vg.ExtentSize)

    for line in device_show_data(ns, lv, human_friendly):
        yield line
Exemple #30
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))