From 55747e450f02afa86ebf2c02153a3db6c65cc67a Mon Sep 17 00:00:00 2001 From: Jose Castillo Date: Wed, 29 Nov 2023 14:52:12 +0000 Subject: [PATCH] [lvm2] Capture PV headers and metadata with pvck Capture PV headers and metadata when a new option, lvm2.metadata , disabled by default, is specified as plugin option. Signed-off-by: Jose Castillo --- sos/report/plugins/lvm2.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/sos/report/plugins/lvm2.py b/sos/report/plugins/lvm2.py index 62917b9a66..27ac4edc95 100644 --- a/sos/report/plugins/lvm2.py +++ b/sos/report/plugins/lvm2.py @@ -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): @@ -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) @@ -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 :