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 contents of the file /etc/lvm/lvm.conf.

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_all

LvsHeadings - command /sbin/lvs -a -o +lv_tags,devices --config="global{locking_type=0}"

LvmConf - file /etc/lvm/lvm.conf

class insights.parsers.lvm.Lvm(context, extra_bad_lines=[])[source]

Bases: insights.core.CommandParser

Base class for parsing LVM data in key=value format.

property locking_disabled

Returns True if any lines in input data indicate locking is disabled.

Type

bool

parse_content(content)[source]

This method must be implemented by classes based on this class.

property 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

>>> lvm_conf_data = shared[LvmConf]
>>> lvm_conf_data.data
{"locking_type": 1, "volume_list": ["vg1", "vg2/lvol1", "@tag1", "@*"],
 "filter": ["a/sda[0-9]*$/", "r/sd.*/"], "history_size": 100}
>>> lvm_conf_data.get("locking_type")
1
parse_content(content)[source]

Returns a dict: locking_type : 1 filter : [‘a/sda[0-9]*$/’, ‘r/sd.*/’] volume_list : [‘vg2’, ‘vg3/lvol3’, @tag2’, ‘@*’]

class insights.parsers.lvm.LvmHeadings(context, extra_bad_lines=[])[source]

Bases: insights.core.CommandParser

Base class for parsing LVM data in table format.

class insights.parsers.lvm.Lvs(context, extra_bad_lines=[])[source]

Bases: insights.parsers.lvm.Lvm

Parse the output of the /sbin/lvs --nameprefixes --noheadings --separator=’|’ -a -o lv_all 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',
        ...
    }
]
parse_content(content)[source]

This method must be implemented by classes based on this class.

vg(name)[source]

Return all logical volumes in the given volume group

class insights.parsers.lvm.LvsAll(context, extra_bad_lines=[])[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=[])[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

Examples

>>> lvs_info = shared[LvsHeadings]
>>> lvs_info.data[0]
{'LV': 'lv_app', 'VG': 'vg_root', 'Attr': '-wi-ao----', 'LSize': '71.63',
 'Pool': '', 'Origin': '', 'Data%': '', 'Meta%': '', 'Move': '', 'Log': '',
 'Cpy%Sync': '', 'Convert': '', 'LV_Tags': '', 'Devices': '/dev/sda2(7136)'}
>>> lvs_info.data[2]['LSize']
'2.00g'
parse_content(content)[source]

This method must be implemented by classes based on this class.

class insights.parsers.lvm.Pvs(context, extra_bad_lines=[])[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.

parse_content(content)[source]

This method must be implemented by classes based on this class.

vg(name)[source]

Return all physical volumes assigned to the given volume group

class insights.parsers.lvm.PvsAll(context, extra_bad_lines=[])[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=[])[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

Examples

>>> pvs_data = shared[PvsHeadings]
>>> pvs_data[0]
{'PV': '/dev/fedora/home', 'VG': '', 'Fmt': '', 'Attr': '---', 'PSize': '0',
 'PFree': '0', 'DevSize': '418.75g', 'PV_UUID': '', 'PMdaFree': '0',
 'PMdaSize': '0', '#PMda': '0', '#PMdaUse': '0', 'PE': '0', 'PV_KEY': '/dev/fedora/home+no_uuid'}
>>> pvs_data[0]['PV']
'/dev/fedora/home'
parse_content(content)[source]

This method must be implemented by classes based on this class.

vg(name)[source]

Return all physical volumes assigned to the given volume group

class insights.parsers.lvm.Vgs(context, extra_bad_lines=[])[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=[])[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=[])[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

Examples

>>> vgs_info = shared[VgsHeadings]
>>> vgs_info.data[0]
{}
>>> vgs_info.data[2]['LSize']
'2.00g'
parse_content(content)[source]

This method must be implemented by classes based on this class.

insights.parsers.lvm.cls

alias of insights.parsers.lvm.Vgs

insights.parsers.lvm.find_warnings(content)[source]

Look for lines containing warning/error/info strings instead of data.

insights.parsers.lvm.map_keys(pvs, keys)[source]

Add human readable key names to dictionary while leaving any existing key names.