Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lvm2] Capture PV headers and metadata with pvck #3429

Merged
merged 1 commit into from
Dec 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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):
""" 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 :