Merge ~sylvain-pineau/checkbox-support:run_lsblk_from_udev_parser_entry_point into checkbox-support:master

Proposed by Sylvain Pineau
Status: Merged
Approved by: Sylvain Pineau
Approved revision: 64c5c5bfecf1915a85d8b440dfc8fb4f932003d2
Merged at revision: ce76dc78019c33cfdecc3faf847e9225bcca2f5b
Proposed branch: ~sylvain-pineau/checkbox-support:run_lsblk_from_udev_parser_entry_point
Merge into: checkbox-support:master
Diff against target: 38 lines (+8/-1)
2 files modified
checkbox_support/parsers/tests/test_udevadm.py (+1/-1)
checkbox_support/parsers/udevadm.py (+7/-0)
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Approve
Review via email: mp+309665@code.launchpad.net

Description of the change

This patch ensures that we're calling lsblk to properly categorize disk devices as such even with the following invocation:

udevadm info --export-db | plainbox dev parse udevadm

Note: The above command is used by the new json report.

To post a comment you must log in.
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

self-approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/checkbox_support/parsers/tests/test_udevadm.py b/checkbox_support/parsers/tests/test_udevadm.py
index 69a4ac3..752feeb 100644
--- a/checkbox_support/parsers/tests/test_udevadm.py
+++ b/checkbox_support/parsers/tests/test_udevadm.py
@@ -89,7 +89,7 @@ class TestUdevadmParser(TestCase, UdevadmDataMixIn):
89 for i,j in enumerate(devices):89 for i,j in enumerate(devices):
90 print(i, j.category, [getattr(j, a) for a in attributes])90 print(i, j.category, [getattr(j, a) for a in attributes])
91 """91 """
92 lsblk=None92 lsblk = ''
93 if with_lsblk:93 if with_lsblk:
94 lsblk = self.get_lsblk(name)94 lsblk = self.get_lsblk(name)
95 return parse_udevadm_output(95 return parse_udevadm_output(
diff --git a/checkbox_support/parsers/udevadm.py b/checkbox_support/parsers/udevadm.py
index 18e5b8e..db81070 100644
--- a/checkbox_support/parsers/udevadm.py
+++ b/checkbox_support/parsers/udevadm.py
@@ -22,6 +22,7 @@ from __future__ import print_function
22from __future__ import unicode_literals22from __future__ import unicode_literals
2323
24from collections import OrderedDict24from collections import OrderedDict
25from subprocess import check_output, CalledProcessError
25import re26import re
26import string27import string
2728
@@ -1046,6 +1047,12 @@ def parse_udevadm_output(output, lsblk=None, bits=None):
1046 :returns: :class:`UdevadmParser` object that corresponds to the1047 :returns: :class:`UdevadmParser` object that corresponds to the
1047 parsed input1048 parsed input
1048 """1049 """
1050 if lsblk is None:
1051 try:
1052 lsblk = check_output(
1053 ['lsblk', '-i', '-n', '-P', '-o', 'KNAME,TYPE,MOUNTPOINT'])
1054 except CalledProcessError as exc:
1055 lsblk = ''
1049 udev = UdevadmParser(output, lsblk, bits)1056 udev = UdevadmParser(output, lsblk, bits)
1050 result = UdevResult()1057 result = UdevResult()
1051 udev.run(result)1058 udev.run(result)

Subscribers

People subscribed via source and target branches