-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix zpool-status parser when there are no columnar values
- Loading branch information
1 parent
8a3997c
commit 5171378
Showing
6 changed files
with
45 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,7 +138,7 @@ | |
|
||
class info(): | ||
"""Provides parser metadata (version, author, etc.)""" | ||
version = '1.1' | ||
version = '1.2' | ||
description = '`zpool status` command parser' | ||
author = 'Kelly Brazil' | ||
author_email = '[email protected]' | ||
|
@@ -182,11 +182,11 @@ def _build_config_list(string: str) -> List[Dict]: | |
|
||
line_list = line.strip().split(maxsplit=5) | ||
config_obj: Dict = {} | ||
config_obj['name'] = line_list[0] | ||
config_obj['state'] = line_list[1] | ||
config_obj['read'] = line_list[2] | ||
config_obj['write'] = line_list[3] | ||
config_obj['checksum'] = line_list[4] | ||
config_obj['name'] = line_list[0] if len(line_list) > 0 else None | ||
config_obj['state'] = line_list[1] if len(line_list) > 1 else None | ||
config_obj['read'] = line_list[2] if len(line_list) > 2 else None | ||
config_obj['write'] = line_list[3] if len(line_list) > 3 else None | ||
config_obj['checksum'] = line_list[4] if len(line_list) > 4 else None | ||
if len(line_list) == 6: | ||
config_obj['errors'] = line_list[5] | ||
config_list.append(config_obj) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"pool":"tank","state":"ONLINE","scan":"scrub repaired 0B in <snip>","config":[{"name":"tank","state":"ONLINE","read":0,"write":0,"checksum":0},{"name":"mirror-0","state":"ONLINE","read":0,"write":0,"checksum":0},{"name":"sdh","state":"ONLINE","read":0,"write":0,"checksum":0},{"name":"sdk","state":"ONLINE","read":0,"write":0,"checksum":0},{"name":"mirror-1","state":"ONLINE","read":0,"write":0,"checksum":0},{"name":"sdl","state":"ONLINE","read":0,"write":0,"checksum":0},{"name":"sdj","state":"ONLINE","read":0,"write":0,"checksum":0},{"name":"mirror-2","state":"ONLINE","read":0,"write":0,"checksum":0},{"name":"sdn","state":"ONLINE","read":0,"write":0,"checksum":0},{"name":"sdm","state":"ONLINE","read":0,"write":0,"checksum":0},{"name":"mirror-3","state":"ONLINE","read":0,"write":0,"checksum":0},{"name":"sdg","state":"ONLINE","read":0,"write":0,"checksum":0},{"name":"sdi","state":"ONLINE","read":0,"write":0,"checksum":0},{"name":"spares","state":null,"read":null,"write":null,"checksum":null},{"name":"sdf","state":"AVAIL","read":null,"write":null,"checksum":null}],"errors":"No known data errors"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
pool: tank | ||
state: ONLINE | ||
scan: scrub repaired 0B in <snip> | ||
config: | ||
|
||
NAME STATE READ WRITE CKSUM | ||
tank ONLINE 0 0 0 | ||
mirror-0 ONLINE 0 0 0 | ||
sdh ONLINE 0 0 0 | ||
sdk ONLINE 0 0 0 | ||
mirror-1 ONLINE 0 0 0 | ||
sdl ONLINE 0 0 0 | ||
sdj ONLINE 0 0 0 | ||
mirror-2 ONLINE 0 0 0 | ||
sdn ONLINE 0 0 0 | ||
sdm ONLINE 0 0 0 | ||
mirror-3 ONLINE 0 0 0 | ||
sdg ONLINE 0 0 0 | ||
sdi ONLINE 0 0 0 | ||
spares | ||
sdf AVAIL | ||
|
||
errors: No known data errors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters