Merge ~pwlars/plainbox-provider-resource:dmi-present into plainbox-provider-resource:master

Proposed by Paul Larson
Status: Merged
Approved by: Paul Larson
Approved revision: a1146059cca24084ada84ea0968751f3cf96c03e
Merged at revision: faf8366e465d3cbe7dfc332b57672189b0aee4e9
Proposed branch: ~pwlars/plainbox-provider-resource:dmi-present
Merge into: plainbox-provider-resource:master
Diff against target: 67 lines (+19/-14)
2 files modified
bin/dmi_resource (+5/-13)
jobs/resource.pxu (+14/-1)
Reviewer Review Type Date Requested Status
Jonathan Cave (community) Approve
Review via email: mp+328045@code.launchpad.net

Description of the change

Here's a slightly different approach to detecting if the dmi data is present. This way we don't add extraneous entries to the dmi data that gets collected. I'm trying to test this on dragonboard, but no luck so far because I'm having some weird lxml/gcc problem when snapcraft tries to build it locally.

To post a comment you must log in.
Revision history for this message
Jonathan Cave (jocave) wrote :

I prefer this approach. IMO, it keeps the original resource output sane.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/bin/dmi_resource b/bin/dmi_resource
2index ac2879b..4dfbb99 100755
3--- a/bin/dmi_resource
4+++ b/bin/dmi_resource
5@@ -30,7 +30,7 @@ COMMAND = "dmidecode"
6 class DmiResult:
7
8 attributes = ("path", "category", "product", "vendor", "serial",
9- "version", "size", "form",)
10+ "version", "size", "form",)
11
12 def addDmiDevice(self, device):
13 for attribute in self.attributes:
14@@ -42,19 +42,11 @@ class DmiResult:
15
16
17 def main():
18+ stream = os.popen(COMMAND)
19+ dmi = DmidecodeParser(stream)
20
21- if os.path.exists('/sys/devices/virtual/dmi'):
22- print("supported: True")
23- print()
24-
25- stream = os.popen(COMMAND)
26- dmi = DmidecodeParser(stream)
27-
28- result = DmiResult()
29- dmi.run(result)
30- else:
31- print("supported: False")
32- print()
33+ result = DmiResult()
34+ dmi.run(result)
35 return 0
36
37
38diff --git a/jobs/resource.pxu b/jobs/resource.pxu
39index f9834eb..89240d7 100644
40--- a/jobs/resource.pxu
41+++ b/jobs/resource.pxu
42@@ -144,11 +144,24 @@ _description:
43 transformations applied are basic changes to make the format compatible with
44 RFC822 syntax required by PlainBox.
45
46+id: dmi_present
47+estimated_duration: 0.02
48+plugin: resource
49+user: root
50+command:
51+ if [ -d /sys/devices/virtual/dmi ]
52+ then
53+ echo "state: supported"
54+ else
55+ echo "state: unsupported"
56+ fi
57+_summary: Resource to detect if dmi data is present
58+
59 id: dmi
60 estimated_duration: 0.59
61 plugin: resource
62 requires:
63- cpuinfo.platform in ("i386", "x86_64")
64+ dmi_present.state == 'supported'
65 user: root
66 command: dmi_resource
67 _summary: Collect information about hardware devices (DMI)

Subscribers

People subscribed via source and target branches