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

NAS-132010 / 25.04 / add zvols to zvol_config.txt #229

Merged
merged 2 commits into from
Oct 28, 2024
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
16 changes: 9 additions & 7 deletions ixdiagnose/plugins/zfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ def zfs_getacl_impl(dataset_name: str, props_dict: dict) -> str:


def resource_output(client: MiddlewareClient, resource_type: str) -> str:
if resource_type == 'zfs':
cp = run(['zfs', 'get', 'all', '-t', 'filesystem'], check=False)
if resource_type in ('filesystem', 'volume'):
cp = run(['zfs', 'get', 'all', '-t', resource_type], check=False)
else:
cp = run([resource_type, 'get', 'all'], check=False)
if cp.returncode:
return f'Failed to retrieve {resource_type!r} resources: {cp.stderr}'

base = 'zpool get all' if resource_type == 'zpool' else 'zfs get all'
prop_list = {'acltype', 'mounted', 'mountpoint'}
resource_context = resource_name = None
output = ''
Expand All @@ -46,24 +47,24 @@ def resource_output(client: MiddlewareClient, resource_type: str) -> str:
for index, resource_line in enumerate(filter(bool, map(str.strip, output_lines[1:]))):
resource_name = resource_line.split()[0].strip()
if resource_context != resource_name:
if resource_context is not None and resource_type == 'zfs':
if resource_context is not None and resource_type == 'filesystem':
output += zfs_getacl(resource_context, prop_dict)

prop_dict = {}
header_str = f'{resource_type} get all {resource_name}'
header_str = f'{base} {resource_name}'
next_line = '\n\n' if index != 0 else ''
output += f'{next_line}{"=" * (len(header_str) + 5)}\n {header_str}\n{"=" * (len(header_str) + 5)}\n\n'
output += f'{props_header}\n'
resource_context = resource_name

if resource_type == 'zfs':
if resource_type == 'filesystem':
prop = resource_line.split()[1]
if prop in prop_list:
prop_dict[prop] = resource_line.split()[2]

output += f'{resource_line}\n'

if resource_name is not None and resource_type == 'zfs':
if resource_name is not None and resource_type == 'filesystem':
output += zfs_getacl(resource_name, prop_dict)

return output
Expand Down Expand Up @@ -128,7 +129,8 @@ class ZFS(Plugin):
),
]
),
PythonMetric('dataset_config', resource_output, 'zfs', 'ZFS Datasets Configuration', serializable=False),
PythonMetric('dataset_config', resource_output, 'filesystem', 'ZFS Datasets Configuration', serializable=False),
PythonMetric('zvol_config', resource_output, 'volume', 'ZFS ZVOL Configuration', serializable=False),
PythonMetric('pool_config', resource_output, 'zpool', 'ZFS Pools Configuration', serializable=False),
]
serializable_metrics = [
Expand Down
Loading