Lvm - Combiner for lvm information

This shared combiner for LVM parsers consolidates all of the information for the following information:

  • LVS

  • PVS

  • VGS

The parsers gather this information from multiple locations such as Insights data and SOS Report data and combines the data. Sample input data and examples are shown for LVS, with PVS and VGS being similar.

Sample input data for LVS commands as parsed by the parsers:

# Output of the command:
# /sbin/lvs -a -o +lv_tags,devices --config="global{locking_type=0}"
WARNING: Locking disabled. Be careful! This could corrupt your metadata.
LV   VG   Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert LV Tags Devices
root rhel -wi-ao---- 17.47g                                                             /dev/vda2(512)
swap rhel -wi-ao----  2.00g                                                             /dev/vda2(0)

# Output of the command:
# /sbin/lvs --nameprefixes --noheadings --separator='|' -a -o lv_name,vg_name,lv_size,region_size,mirror_log,lv_attr,devices,region_size --config="global{locking_type=0}"
WARNING: Locking disabled. Be careful! This could corrupt your metadata.
LVM2_LV_NAME='root'|LVM2_VG_NAME='rhel'|LVM2_LV_SIZE='17.47g'|LVM2_REGION_SIZE='0 '|LVM2_MIRROR_LOG=''|LVM2_LV_ATTR='-wi-ao----'|LVM2_DEVICES='/dev/vda2(512)'|LVM2_REGION_SIZE='0 '
LVM2_LV_NAME='swap'|LVM2_VG_NAME='rhel'|LVM2_LV_SIZE='2.00g'|LVM2_REGION_SIZE='0 '|LVM2_MIRROR_LOG=''|LVM2_LV_ATTR='-wi-ao----'|LVM2_DEVICES='/dev/vda2(0)'|LVM2_REGION_SIZE='0 '

Because logical volume names may be duplicated on different volume groups, the key used for the logical volume information is a named tuple of type LvVgName. Physical volumes and volume groups do not have the same limitation so the key used for that information is simply the string name of the physical device or volume group.

Examples

>>> lvm_info = shared[Lvm]
>>> lvm_info.logical_volumes[LvVgName(LV='root', VG='rhel')]
{
    'Log': '', 'LPerms': None, 'Health': None, 'MaxSync': None, 'Pool_UUID': None, 'DevOpen': None, 'SkipAct': None,
    'Parent': None, 'Descendants': None, 'WhenFull': None, 'Lock_Args': None, 'CacheReadMisses': None, 'Host': None,
    'CacheWriteHits': None, 'Active': None, 'Path': None, 'LV_UUID': None, 'Data': None, 'LV_Tags': None, 'Pool': None,
    'CacheDirtyBlocks': None, 'InitImgSync': None, 'Region': '0', 'LiveTable': None, 'MinSync': None,
    'Devices': '/dev/vda2(512)', 'ActLocal': None, 'Time': None, 'Cpy%Sync': None, 'Modules': None, 'Data_UUID': None, 'Origin': None,
    'Move': None, 'Origin_UUID': None, 'Converting': None, 'LSize': '17.47g', '#Seg': None, 'Ancestors': None, 'Layout': None,
    'Meta%': None, 'Min': None, 'Data%': None, 'AllocLock': None, 'CacheWriteMisses': None, 'AllocPol': None,
    'CacheTotalBlocks': None, 'MergeFailed': None, 'Mismatches': None, 'WBehind': None, 'ActExcl': None, 'ActRemote': None,
    'OSize': None, 'KMin': None, 'LV': 'root', 'InactiveTable': None, 'Move_UUID': None, 'Maj': None, 'Role': None, 'KMaj': None,
    'Convert': None, 'LProfile': None, 'Attr': '-wi-ao----', 'VG': 'rhel', 'KRahead': None, 'Rahead': None, 'Log_UUID': None,
    'MSize': None, 'Merging': None, 'DMPath': None, 'Meta_UUID': None, 'SnapInvalid': None, 'ImgSynced': None,
    'CacheReadHits': None, 'Meta': None, 'Snap%': None, 'Suspended': None, 'FixMin': None, 'CacheUsedBlocks': None, 'SyncAction': None
}
>>> lvm_info.logical_volumes[LvVgName('root','rhel')]['LSize']
'17.47g'
>>> lvm_info.logical_volume_names
{LvVgName(LV='root', VG='rhel'), LvVgName(LV='swap', VG='rhel')}
>>> lvm_info.filter_logical_volumes(lv_filter='root')
{LvVgName(LV='root', VG='rhel'): {
    'Log': '', 'LPerms': None, 'Health': None, 'MaxSync': None, 'Pool_UUID': None, 'DevOpen': None, 'SkipAct': None,
    'Parent': None, 'Descendants': None, 'WhenFull': None, 'Lock_Args': None, 'CacheReadMisses': None, 'Host': None,
    'CacheWriteHits': None, 'Active': None, 'Path': None, 'LV_UUID': None, 'Data': None, 'LV_Tags': None, 'Pool': None,
    'CacheDirtyBlocks': None, 'InitImgSync': None, 'Region': '0', 'LiveTable': None, 'MinSync': None,
    'Devices': '/dev/vda2(512)', 'ActLocal': None, 'Time': None, 'Cpy%Sync': None, 'Modules': None, 'Data_UUID': None, 'Origin': None,
    'Move': None, 'Origin_UUID': None, 'Converting': None, 'LSize': '17.47g', '#Seg': None, 'Ancestors': None, 'Layout': None,
    'Meta%': None, 'Min': None, 'Data%': None, 'AllocLock': None, 'CacheWriteMisses': None, 'AllocPol': None,
    'CacheTotalBlocks': None, 'MergeFailed': None, 'Mismatches': None, 'WBehind': None, 'ActExcl': None, 'ActRemote': None,
    'OSize': None, 'KMin': None, 'LV': 'root', 'InactiveTable': None, 'Move_UUID': None, 'Maj': None, 'Role': None, 'KMaj': None,
    'Convert': None, 'LProfile': None, 'Attr': '-wi-ao----', 'VG': 'rhel', 'KRahead': None, 'Rahead': None, 'Log_UUID': None,
    'MSize': None, 'Merging': None, 'DMPath': None, 'Meta_UUID': None, 'SnapInvalid': None, 'ImgSynced': None,
    'CacheReadHits': None, 'Meta': None, 'Snap%': None, 'Suspended': None, 'FixMin': None, 'CacheUsedBlocks': None, 'SyncAction': None
}}
class insights.combiners.lvm.Lvm(lvs, lvs_headings, pvs, pvs_headings, vgs, vgs_headings)[source]

Bases: object

Class implements shared combiner for LVM information.

class LvVgName(LV, VG)

Bases: tuple

Named tuple used as key for logical volumes.

property LV
property VG
filter_logical_volumes(lv_filter, vg_filter=None)[source]

dict: Returns dictionary of logical volume information having the lv_filter in the logical volume and if specified vg_filter in the volume group.

filter_physical_volumes(pv_filter)[source]

dict: Returns dictionary of physical volume information with keys containing pv_filter.

filter_volume_groups(vg_filter)[source]

dict: Returns dictionary of volume group information with keys containing vg_filter.

property logical_volume_names

Returns a set of tuple keys from the logical volume information.

Type

set

logical_volumes = None

Contains a dictionary of logical volume data with keys from the original output. The key is a tuple of the logical volume name and the volume group name. This tuple avoids the case where logical volume names are the same across volume groups.

Type

dict

physical_volumes = None

Contains a dictionary of physical volume data with keys from the original output.

Type

dict

property volume_group_names

Returns a set of keys from the volume group information.

Type

set

volume_groups = None

Contains a dictionary of volume group data with keys from the original output.

Type

dict

class insights.combiners.lvm.LvmAll(lvsall, pvsall, vgsall)[source]

Bases: insights.combiners.lvm.Lvm

A Lvm like shared combiner for processing LVM information including all rejected and accepted devices

logical_volumes = None

Contains a dictionary of logical volume data with keys from the original output. The key is a tuple of the logical volume name and the volume group name. This tuple avoids the case where logical volume names are the same across volume groups.

Type

dict

physical_volumes = None

Contains a dictionary of physical volume data with keys from the original output.

Type

dict

volume_groups = None

Contains a dictionary of volume group data with keys from the original output.

Type

dict

insights.combiners.lvm.get_shared_data(component)[source]

Returns the actual list of component data based on how data is stored in component, either from the data attribute or from the data[‘content’] attribute.

Returns

List of component data.

Return type

list

insights.combiners.lvm.merge_lvm_data(primary, secondary, name_key)[source]

Returns a dictionary containing the set of data from primary and secondary where values in primary will always be returned if present, and values in secondary will only be returned if not present in primary, or if the value in primary is None.

Sample input Data:

primary = [
    {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'name_key': 'xyz'},
    {'a': None, 'b': 12, 'c': 13, 'd': 14, 'name_key': 'qrs'},
    {'a': None, 'b': 12, 'c': 13, 'd': 14, 'name_key': 'def'},
]
secondary = [
    {'a': 31, 'e': 33, 'name_key': 'xyz'},
    {'a': 11, 'e': 23, 'name_key': 'qrs'},
    {'a': 1, 'e': 3, 'name_key': 'ghi'},
]
Returns

Dictionary of key value pairs from obj1 and obj2:

{
    'xyz': {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 33, 'name_key': 'xyz'},
    'qrs': {'a': 11, 'b': 12, 'c': 13, d: 14, e: 23, 'name_key': 'qrs'},
    'def': {'a': None, 'b': 12, 'c': 13, 'd': 14, 'name_key': 'def'},
    'ghi': {'a': 1, 'e': 3, 'name_key': 'ghi'}
}

Return type

dict

insights.combiners.lvm.set_defaults(lvm_data)[source]

dict: Sets all existing null string values to None.

insights.combiners.lvm.to_name_key_dict(data, name_key)[source]

Iterates a list of dictionaries where each dictionary has a name_key value that is used to return a single dictionary indexed by those values.

Returns

Dictionary keyed by name_key values having the information

contained in the original input list data.

Return type

dict