Skip to content

Commit

Permalink
[lvm2] Capture PV headers and metadata with pvck
Browse files Browse the repository at this point in the history
Capture PV headers and metadata when a new option,
lvm2.metadata , disabled by default, is specified
as plugin option.

Signed-off-by: Jose Castillo <[email protected]>
  • Loading branch information
jcastill committed Nov 29, 2023
1 parent ffeb7d9 commit 55747e4
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion sos/report/plugins/lvm2.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ class Lvm2(Plugin, IndependentPlugin):
PluginOpt('lvmdump', default=False, desc='collect an lvmdump tarball'),
PluginOpt('lvmdump-am', default=False,
desc=('attempt to collect lvmdump with advanced options and '
'raw metadata'))
'raw metadata')),
PluginOpt('metadata', default=False,
desc=('attempt to collect headers and metadata via pvck'))
]

def do_lvmdump(self, metadata=False):
Expand All @@ -39,6 +41,24 @@ def do_lvmdump(self, metadata=False):

self.add_cmd_output(cmd, chroot=self.tmp_in_sysroot())

def get_pvck_output(self, metadata=False):
""" Collects the output of the command pvck for each block device
present in the system.
"""

block_list = self.exec_cmd(
'pvs -o pv_name --no-headings'
)
if block_list['status'] == 0:
for line in block_list['output'].splitlines():
cmds = [
f"pvck --dump headers {line}",
f"pvck --dump metadata {line}",
f"pvck --dump metadata_all {line} -v",
f"pvck --dump metadata_search {line} -v"
]
self.add_cmd_output(cmds, subdir="metadata")

def setup(self):
# When running LVM2 comamnds:
# - use nolocking if supported, else locking_type 0 (no locks)
Expand Down Expand Up @@ -92,4 +112,7 @@ def setup(self):
elif self.get_option('lvmdump-am'):
self.do_lvmdump(metadata=True)

if self.get_option('metadata'):
self.get_pvck_output()

# vim: set et ts=4 sw=4 :

0 comments on commit 55747e4

Please sign in to comment.