Logical Volume Management configuration and status¶
Parsers for lvm data based on output of various commands and file contents.
This module contains the classes that parse the output of the commands lvs, pvs, and vgs, and the content of the files /etc/lvm/lvm.conf, /etc/lvm/devices/system.devices.
Pvs - command /sbin/pvs --nameprefixes --noheadings --separator='|' -a -o pv_all
¶
PvsHeadings - command pvs -a -v -o +pv_mda_free,pv_mda_size,pv_mda_count,pv_mda_used_count,pe_count --config="global{locking_type=0}"
¶
Vgs - command /sbin/vgs --nameprefixes --noheadings --separator='|' -a -o vg_all
¶
VgsHeadings - command vgs -v -o +vg_mda_count,vg_mda_free,vg_mda_size,vg_mda_used_count,vg_tags --config="global{locking_type=0}"
¶
Lvs - command /sbin/lvs --nameprefixes --noheadings --separator='|' -a -o lv_name,lv_size,lv_attr,mirror_log,vg_name,devices,region_size,data_percent,metadata_percent,segtype,seg_monitor --config="global{locking_type=0}"
¶
LvsHeadings - command /sbin/lvs -a -o +lv_tags,devices --config="global{locking_type=0}"
¶
LvmConf - file /etc/lvm/lvm.conf
¶
LvmSystemDevices - file /etc/lvm/devices/system.devices
¶
LvmFullReport - command /sbin/lvm fullreport -a --reportformat json
¶
-
class
insights.parsers.lvm.
Lvm
(context, extra_bad_lines=None)[source]¶ Bases:
insights.core.CommandParser
Base class for parsing LVM data in key=value format.
-
locking_disabled
¶ Returns True if any lines in input data indicate locking is disabled.
Type: bool
-
warnings
¶ Returns a list of lines from input data containing warning/error/info strings.
Type: list
-
-
class
insights.parsers.lvm.
LvmConf
(context)[source]¶ Bases:
insights.core.LegacyItemAccess
,insights.core.Parser
Parses contents of the /etc/lvm/lvm.conf file.
Sample Input:
locking_type = 1 #locking_type = 2 # volume_list = [ "vg1", "vg2/lvol1", "@tag1", "@*" ] volume_list = [ "vg2", "vg3/lvol3", "@tag2", "@*" ] # filter = [ "a|loop|", "r|/dev/hdc|", "a|/dev/ide|", "r|.*|" ] filter = [ "r/sda[0-9]*$/", "a/sd.*/" ] filter = [ "a/sda[0-9]*$/", "r/sd.*/" ] shell { history_size = 100 }
Examples
>>> 'vg2' in lvm_conf_data.data.get('volume_list') True >>> lvm_conf_data.get("locking_type") 1
-
class
insights.parsers.lvm.
LvmConfig
(context, extra_bad_lines=None)[source]¶ Bases:
insights.core.CommandParser
-
class
insights.parsers.lvm.
LvmFullReport
(context)[source]¶ Bases:
insights.core.JSONParser
Parse the output of the command
/usr/sbin/lvm fullreport -a --reportformat json
. Output is in JSON format so the JSONParser will be used.Sample input (actual input is in JSON format, data has been changed here to show the relationship between volume groups, physical valumes and logical volumes):
{ "report": [ { "vg": [ { vg_name:vg1, vg_uuid:111, properties of vg1 } ], "pv": [ { pv_name:/dev/foo, pv_uuid:222, properties of foo }, { pv_name:/dev/bar, pv_uuid:333, properties of bar }, more pvs ], "lv": [ { lv_name:lv1, lv_uuid:444, properties of lv1 }, { lv_name:lv2, lv_uuid:555, properties of lv2 }, more lvs ], "pvseg": [ { ..., pv_uuid:222, ... }, { ..., pv_uuid:222, ... }, { ..., pv_uuid:333, ... }, more pvsegs ], "seg": [ { ..., lv_uuid:444, ... }, { ..., lv_uuid:555, ... }, { ..., lv_uuid:555, ... }, more segs ] }, { "vg": [ { vg_name:rhel, vg_uuid:112, properties of rhel } ], "pv": [ { pv_name:/dev/foo2, pv_uuid:223, properties of foo2 }, { pv_name:/dev/bar2, pv_uuid:334, properties of bar2 }, more pvs ], "lv": [ { lv_name:lv12, lv_uuid:442, properties of lv12 }, { lv_name:lv22, lv_uuid:5552, properties of lv22 }, more lvs ], "pvseg": [ { ..., pv_uuid:223, ... }, { ..., pv_uuid:223, ... }, { ..., pv_uuid:334, ... }, more pvsegs ], "seg": [ { ..., lv_uuid:442, ... }, { ..., lv_uuid:5552, ... }, { ..., lv_uuid:5552, ... }, more segs ] }, # Orphan volume group (pv's not associated with a vg) { "pv": [ {...} ], "pvseg": [ {...} ] } ] }
Output will be a python object in the same structure as the JSON:
{ "report": [ { "vg": [ {"vg_name": "vg1", ...}, ... ], "pv": [ {"pv_name": "/dev/sdg", ...), ... ], "lv": [ {"lv_name": "[fast1_cvol]", ...}, ... ], "pvseg": [ {"pvseg_start": "0", ...}, ... ], "seg": [ {"segtype": "cache-pool", ...}, ... ] }, { "vg": [ {"vg_name": "rhel", ...}, ... ], "pv": [ {"pv_name": "/dev/sdd", ...), ... ], "lv": [ {"lv_name": "[lvm_lock]", ...}, ... ], "pvseg": [ {"pvseg_start": "0", ...}, ... ], "seg": [ {"segtype": "linear", ...}, ... ] }, ... { "pv": [ {...} ], "pvseg": [ {...} ] } ] }
-
warnings
¶ List of warning lines included at the beginning of input
Type: list
-
volume_groups
¶ Dictionary with vg_name as the key, contains a dictionary including all information for the volume group. The vg element is represented as a list but will only have a single item which is that volumn group:
{ "vg1": { "vg": [ {"vg_name": "global", ...}, ... ], "pv": [ {"pv_name": "/dev/sdd", ...), ... ], "lv": [ {"lv_name": "[lvm_lock]", ...}, ... ], "pvseg": [ {"pvseg_start": "0", ...}, ... ], "seg": [ {"segtype": "linear", ...}, ... ] }, ... }
Type: dict
-
orphan_volume_group
¶ Dictionary of pv’s and pvseg’s not associated with a volume group:
{ "pv": [ {"pv_name": "/dev/sda", ...), ... ], "pvseg": [ {"pvseg_start": "0", ...}, ... ], }
Type: dict
Example
>>> type(lvm_fullreport) <class 'insights.parsers.lvm.LvmFullReport'> >>> len(lvm_fullreport.volume_groups) 2 >>> sorted(lvm_fullreport.volume_groups.keys()) == ['rhel', 'vg1'] True >>> lvm_fullreport.volume_groups['vg1']['pv'][0]['pv_name'] == '/dev/vdb' True
Raises: SkipComponent
-- when there is no device info.-
-
class
insights.parsers.lvm.
LvmHeadings
(context, extra_bad_lines=None)[source]¶ Bases:
insights.core.CommandParser
Base class for parsing LVM data in table format.
-
class
insights.parsers.lvm.
LvmSystemDevices
(context)[source]¶ Bases:
insights.core.Parser
,dict
Parse the content of the
/etc/lvm/devices/system.devices
file. It returns a dict. The key is the device id, the value is a dict of other info.Sample input:
VERSION=1.1.2 IDTYPE=devname IDNAME=/dev/vda2 DEVNAME=/dev/vda2 PVID=phl0clFbAokp9UXqbIgI5YYQxuTIJVkD PART=2
Sample output:
{ '/dev/vda2': { 'IDTYPE': 'devname', 'DEVNAME': '/dev/vda2', 'PVID': 'phl0clFbAokp9UXqbIgI5YYQxuTIJVkD', 'PART': '2' } }
Example
>>> type(devices) <class 'insights.parsers.lvm.LvmSystemDevices'> >>> devices['/dev/vda2']['IDTYPE'] 'devname' >>> devices['/dev/vda2']['PVID'] 'phl0clFbAokp9UXqbIgI5YYQxuTIJVkD'
Raises: SkipComponent
-- when there is no device info.
-
class
insights.parsers.lvm.
Lvs
(context, extra_bad_lines=None)[source]¶ Bases:
insights.parsers.lvm.Lvm
Parse the output of the /sbin/lvs --nameprefixes --noheadings --separator=’|’ -a -o lv_name,lv_size,lv_attr,mirror_log,vg_name,devices,region_size,data_percent,metadata_percent,segtype,seg_monitor --config=”global{locking_type=0}” command.
Parse each line in the output of lvs based on the lvs datasource in insights/specs/:
Output sample of lvs:
LVM2_LV_UUID='KX68JI-8ISN-YedH-ZYDf-yZbK-zkqE-3aVo6m'|LVM2_LV_NAME='docker-poolmeta'|LVM2_LV_FULL_NAME='rhel/docker-poolmeta'|... LVM2_LV_UUID='123456-8ISN-YedH-ZYDf-yZbK-zkqE-123456'|LVM2_LV_NAME='rhel_root'|LVM2_LV_FULL_NAME='rhel/rhel_root'|LVM2_LV_PATH='/dev/rhel/docker-poolmeta'|...
Return a list, as shown below:
[ { 'LVM2_LV_UUID' : 'KX68JI-8ISN-YedH-ZYDf-yZbK-zkqE-3aVo6m', 'LVM2_LV_NAME' : 'docker-poolmeta', 'LVM2_LV_FULL_NAME' : 'rhel/docker-poolmeta', ... }, { 'LVM2_LV_UUID' : '123456-8ISN-YedH-ZYDf-yZbK-zkqE-123456', 'LVM2_LV_NAME' : 'rhel_root', 'LVM2_LV_FULL_NAME' : 'rhel/rhel_root', ... } ]
-
class
insights.parsers.lvm.
LvsAll
(context, extra_bad_lines=None)[source]¶ Bases:
insights.parsers.lvm.Lvs
Parse the output of the /sbin/lvs --nameprefixes --noheadings --separator=’|’ -a -o lv_name,lv_size,lv_attr,mirror_log,vg_name,devices,region_size,data_percent,metadata_percent --config=’global{locking_type=0} devices{filter=[“a|.*|”]}’ command.
Uses the
Lvs
class defined in this module.
-
class
insights.parsers.lvm.
LvsHeadings
(context, extra_bad_lines=None)[source]¶ Bases:
insights.parsers.lvm.LvmHeadings
Process output of the command /sbin/lvs -a -o +lv_tags,devices --config=”global{locking_type=0}”.
Sample Input data:
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 lv_app vg_root -wi-ao---- 71.63g /dev/sda2(7136) lv_home vg_root -wi-ao---- 2.00g /dev/sda2(2272) lv_opt vg_root -wi-ao---- 5.00g /dev/sda2(2784) lv_root vg_root -wi-ao---- 5.00g /dev/sda2(0) lv_tmp vg_root -wi-ao---- 1.00g /dev/sda2(4064) lv_usr vg_root -wi-ao---- 5.00g /dev/sda2(4320) lv_usrlocal vg_root -wi-ao---- 1.00g /dev/sda2(5600) lv_var vg_root -wi-ao---- 5.00g /dev/sda2(5856) swap vg_root -wi-ao---- 3.88g /dev/sda2(1280)
-
data
¶ List of dicts, each dict containing one row of the table with column headings as keys.
Type: list
-
warnings
¶ Set of lines from input data containing warning strings.
Type: set
Examples
>>> lvs_info.data[0]['Devices'] '/dev/sda2(7136)' >>> lvs_info.data[1]['LSize'] '2.00g'
-
-
class
insights.parsers.lvm.
Pvs
(context, extra_bad_lines=None)[source]¶ Bases:
insights.parsers.lvm.Lvm
Parse the output of the /sbin/pvs --nameprefixes --noheadings --separator=’|’ -a -o pv_all command.
Parse each line in the output of pvs based on the of pvs datasource in insights/specs/ Output sample of pvs:
LVM2_PV_FMT=''|LVM2_PV_UUID=''|LVM2_DEV_SIZE='500.00m'|... LVM2_PV_FMT='lvm2'|LVM2_PV_UUID='JvSULk-ileq-JbuS-GGgg-jkif-thuW-zvFBEl'|LVM2_DEV_SIZE='476.45g'|...
Returns a list like:
[ { 'LVM2_PV_FMT' : '', 'LVM2_PV_UUID' : '', 'LVM2_DEV_SIZE' : '500.00m', ... }, { 'LVM2_PV_FMT' : 'lvm2', 'LVM2_PV_UUID' : 'JvSULk-ileq-JbuS-GGgg-jkif-thuW-zvFBEl', 'LVM2_DEV_SIZE' : '476.45g', ... } ]
Since it is possible to have two PV’s with the same name (for example unknown device) a unique key for each PV is created by joining the PV_NAME and PV_UUID fields with a `+ character. This key is added to the dictionary as the PV_KEY field.
-
class
insights.parsers.lvm.
PvsAll
(context, extra_bad_lines=None)[source]¶ Bases:
insights.parsers.lvm.Pvs
Parse the output of the /sbin/pvs --nameprefixes --noheadings --separator=’|’ -a -o pv_all,vg_name --config=’global{locking_type=0} devices{filter=[“a|.*|”]}’ command.
Uses the
Pvs
class defined in this module.
-
class
insights.parsers.lvm.
PvsHeadings
(context, extra_bad_lines=None)[source]¶ Bases:
insights.parsers.lvm.LvmHeadings
Parses the output of the pvs -a -v -o +pv_mda_free,pv_mda_size,pv_mda_count,pv_mda_used_count,pe_count --config=”global{locking_type=0}” command.
Since it is possible to have two PV’s with the same name (for example unknown device) a unique key for each PV is created by joining the PV_NAME and PV_UUID fields with a `+ character. This key is added to the resulting dictionary as the PV_KEY field.
Sample input:
WARNING: Locking disabled. Be careful! This could corrupt your metadata. Scanning all devices to update lvmetad. No PV label found on /dev/loop0. No PV label found on /dev/loop1. No PV label found on /dev/sda1. No PV label found on /dev/fedora/root. No PV label found on /dev/sda2. No PV label found on /dev/fedora/swap. No PV label found on /dev/fedora/home. No PV label found on /dev/mapper/docker-253:1-2361272-pool. Wiping internal VG cache Wiping cache of LVM-capable devices PV VG Fmt Attr PSize PFree DevSize PV UUID PMdaFree PMdaSize #PMda #PMdaUse PE /dev/fedora/home --- 0 0 418.75g 0 0 0 0 0 /dev/fedora/root --- 0 0 50.00g 0 0 0 0 0 /dev/fedora/swap --- 0 0 7.69g 0 0 0 0 0 /dev/loop0 --- 0 0 100.00g 0 0 0 0 0 /dev/loop1 --- 0 0 2.00g 0 0 0 0 0 /dev/mapper/docker-253:1-2361272-pool --- 0 0 100.00g 0 0 0 0 0 /dev/mapper/luks-7430952e-7101-4716-9b46-786ce4684f8d fedora lvm2 a-- 476.45g 4.00m 476.45g FPLCRf-d918-LVL7-6e3d-n3ED-aiZv-EesuzY 0 1020.00k 1 1 121970 /dev/sda1 --- 0 0 500.00m 0 0 0 0 0 /dev/sda2 --- 0 0 476.45g 0 0 0 0 0 Reloading config files Wiping internal VG cache
-
data
¶ List of dicts, each dict containing one row of the table with column headings as keys.
Type: list
-
warnings
¶ Set of lines from input data containing warning strings.
Type: set
Examples
>>> pvs_data[0]['PV'] '/dev/fedora/home' >>> pvs_data[0]['PMdaSize'] '0'
-
-
class
insights.parsers.lvm.
Vgs
(context, extra_bad_lines=None)[source]¶ Bases:
insights.parsers.lvm.Lvm
Parse the output of the /sbin/vgs --nameprefixes --noheadings --separator=’|’ -a -o vg_all command.
Parse each line in the output of vgs based on the vgs datasource in insights/specs/ Output sample of vgs:
LVM2_VG_FMT='lvm2'|LVM2_VG_UUID='YCpusB-LEly-THGL-YXhC-t3q6-mUQV-wyFZrx'|LVM2_VG_NAME='rhel'|LVM2_VG_ATTR='wz--n-'|... LVM2_VG_FMT='lvm2'|LVM2_VG_UUID='123456-LEly-THGL-YXhC-t3q6-mUQV-123456'|LVM2_VG_NAME='fedora'|LVM2_VG_ATTR='wz--n-'|...
Returns a list like:
[ { 'LVM2_PV_FMT' : 'lvm2', 'LVM2_VG_UUID' : 'YCpusB-LEly-THGL-YXhC-t3q6-mUQV-wyFZrx', 'LVM2_VG_NAME' : 'rhel', ... }, { 'LVM2_PV_FMT' : 'lvm2', 'LVM2_VG_UUID' : '123456-LEly-THGL-YXhC-t3q6-mUQV-123456', 'LVM2_VG_NAME' : 'fedora', ... } ]
-
class
insights.parsers.lvm.
VgsAll
(context, extra_bad_lines=None)[source]¶ Bases:
insights.parsers.lvm.Vgs
Parse the output of the /sbin/vgs --nameprefixes --noheadings --separator=’|’ -a -o vg_all --config=’global{locking_type=0} devices{filter=[“a|.*|”]}’ command.
Uses the
Vgs
class defined in this module.
-
class
insights.parsers.lvm.
VgsHeadings
(context, extra_bad_lines=None)[source]¶ Bases:
insights.parsers.lvm.LvmHeadings
Parses output of the vgs -v -o +vg_mda_count,vg_mda_free,vg_mda_size,vg_mda_used_count,vg_tags --config=”global{locking_type=0}” command.
Sample input:
WARNING: Locking disabled. Be careful! This could corrupt your metadata. Using volume group(s) on command line. VG Attr Ext #PV #LV #SN VSize VFree VG UUID VProfile #VMda VMdaFree VMdaSize #VMdaUse VG Tags DATA_OTM_VG wz--n- 4.00m 6 1 0 2.05t 1020.00m xK6HXk-xl2O-cqW5-2izb-LI9M-4fV0-dAzfcc 6 507.00k 1020.00k 6 ITM_VG wz--n- 4.00m 1 1 0 16.00g 4.00m nws5dd-INe6-1db6-9U1N-F0G3-S1z2-5XTdO4 1 508.00k 1020.00k 1 ORABIN_OTM_VG wz--n- 4.00m 2 3 0 190.00g 0 hfJwg8-hset-YgUY-X6NJ-gkWE-EunZ-KuCXGP 2 507.50k 1020.00k 2 REDO_OTM_VG wz--n- 4.00m 1 3 0 50.00g 0 Q2YtGy-CWKU-sEYj-mqHk-rbdP-Hzup-wi8jsf 1 507.50k 1020.00k 1 SWAP_OTM_VG wz--n- 4.00m 1 1 0 24.00g 8.00g hAerzZ-U8QU-ICkc-xxCj-N2Ny-rWzq-pmTpWJ 1 508.00k 1020.00k 1 rootvg wz--n- 4.00m 1 6 0 19.51g 1.95g p4tLLb-ikeo-Ankk-2xJ6-iHYf-D4E6-KFCFvr 1 506.50k 1020.00k 1 Reloading config files Wiping internal VG cache
-
data
¶ List of dicts, each dict containing one row of the table with column headings as keys.
Type: list
-
warnings
¶ Set of lines from input data containing warning strings.
Type: set
Examples
>>> vgs_info.data[0]['VG'] 'DATA_OTM_VG' >>> vgs_info.data[0]['VG_UUID'] 'xK6HXk-xl2O-cqW5-2izb-LI9M-4fV0-dAzfcc'
-
-
insights.parsers.lvm.
cls
¶ alias of
insights.parsers.lvm.Vgs