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

Fix xfs.py module that can no longer parse output from mkfs.xfs. #60853

Merged
merged 3 commits into from
Sep 27, 2022
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions changelog/60853.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix xfs module when additional output included in mkfs.xfs command.
2 changes: 1 addition & 1 deletion salt/modules/xfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def _parse_xfs_info(data):
spr = re.compile(r"\s+")
entry = None
for line in [spr.sub(" ", l).strip().replace(", ", " ") for l in data.split("\n")]:
if not line:
if not line or "=" not in line:
continue
nfo = _xfs_info_get_kv(line)
if not line.startswith("="):
Expand Down
69 changes: 69 additions & 0 deletions tests/unit/modules/test_xfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,72 @@ def test__blkid_output(self):
}
},
)

def test__parse_xfs_info(self):
"""
Test parsing output from mkfs.xfs.
"""
data = textwrap.dedent(
"""
meta-data=/dev/vg00/testvol isize=512 agcount=4, agsize=1310720 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=5242880, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
Discarding blocks...Done.
"""
)

self.assertEqual(
xfs._parse_xfs_info(data),
{
"meta-data": {
"section": "/dev/vg00/testvol",
"isize": "512",
"agcount": "4",
"agsize": "1310720 blks",
"sectsz": "4096",
"attr": "2",
"projid32bit": "1",
"crc": "1",
"finobt": "1",
"sparse": "1",
"rmapbt": "0",
"reflink": "1",
},
"data": {
"section": "data",
"bsize": "4096",
"blocks": "5242880",
"imaxpct": "25",
"sunit": "0",
"swidth": "0 blks",
},
"naming": {
"section": "version 2",
"bsize": "4096",
"ascii-ci": "0",
"ftype": "1",
},
"log": {
"section": "internal log",
"bsize": "4096",
"blocks": "2560",
"version": "2",
"sectsz": "4096",
"sunit": "1 blks",
"lazy-count": "1",
},
"realtime": {
"section": "none",
"extsz": "4096",
"blocks": "0",
"rtextents": "0",
},
},
)