diff --git a/changelog/60853.fixed b/changelog/60853.fixed new file mode 100644 index 000000000000..3264c66ad7cd --- /dev/null +++ b/changelog/60853.fixed @@ -0,0 +1 @@ +Fix xfs module when additional output included in mkfs.xfs command. diff --git a/salt/modules/xfs.py b/salt/modules/xfs.py index 60329c9a13a4..04b104f9967e 100644 --- a/salt/modules/xfs.py +++ b/salt/modules/xfs.py @@ -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("="): diff --git a/tests/unit/modules/test_xfs.py b/tests/unit/modules/test_xfs.py index 778aff793de2..47b75a045098 100644 --- a/tests/unit/modules/test_xfs.py +++ b/tests/unit/modules/test_xfs.py @@ -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", + }, + }, + )