Merge lp:~bladernr/checkbox/1352376-fix-get_make_and_model-device-tree into lp:checkbox

Proposed by Jeff Lane 
Status: Merged
Approved by: Daniel Manrique
Approved revision: 3161
Merged at revision: 3161
Proposed branch: lp:~bladernr/checkbox/1352376-fix-get_make_and_model-device-tree
Merge into: lp:checkbox
Diff against target: 59 lines (+26/-9)
2 files modified
providers/plainbox-provider-checkbox/bin/get_make_and_model (+25/-8)
providers/plainbox-provider-checkbox/jobs/miscellanea.txt.in (+1/-1)
To merge this branch: bzr merge lp:~bladernr/checkbox/1352376-fix-get_make_and_model-device-tree
Reviewer Review Type Date Requested Status
Daniel Manrique (community) Approve
Jeff Lane  Needs Resubmitting
Review via email: mp+229505@code.launchpad.net

Description of the change

basically a rewrite of get_make_and_model to use lshw instead of directly accessing /sys/class/dmi/id/*. This is to add functionality on device-tree enabled systems (armhf and arm64) as they do not currently provide dmi data/interfaces.

Rather than write platform or interface specific bits for multiple methods to get the same data, lshw is fairly universal (universal enough to catch 99% of our use cases) and provides the same data in a uniform way, regardless of the interface used.

To post a comment you must log in.
Revision history for this message
Daniel Manrique (roadmr) wrote :

One tiny request, could you update the job definition (miscellanea/get_make_and_model) and change the estimated_duration? On my system it takes close to 2.5 seconds so our current timing data is inaccurate. If it takes longer on e.g. armhf, that would be a good value to use.

review: Needs Fixing
3161. By Jeff Lane 

updated estimated time for miscellanea/get_make_and_model to 30 seconds based on tests locally

Revision history for this message
Jeff Lane  (bladernr) wrote :

Ok, updated the time item.

I set it to 30 seconds. it was actually a good deal faster on the ARM systems (that have less data to parse, I suppose) but on my development machine here, it consistently took about 30 seconds on all 10 attempts... so 30 sounds like a safe, conservative estimate.

review: Needs Resubmitting
Revision history for this message
Daniel Manrique (roadmr) wrote :

Awesome, thanks and apologies for the nitpick.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'providers/plainbox-provider-checkbox/bin/get_make_and_model'
2--- providers/plainbox-provider-checkbox/bin/get_make_and_model 2014-07-17 18:15:59 +0000
3+++ providers/plainbox-provider-checkbox/bin/get_make_and_model 2014-08-04 20:53:23 +0000
4@@ -1,17 +1,34 @@
5 #!/usr/bin/env python3
6
7 import os.path
8+import shlex
9+from subprocess import check_output
10
11-def print_file_contents(heading, filename):
12- with open(filename) as f:
13- text = f.read().strip()
14- print("{}: {}".format(heading, text))
15- f.close()
16+def print_data(key, value):
17+ print("{}: {}".format(key, value))
18
19 def main():
20- print_file_contents('Manufacturer', '/sys/class/dmi/id/sys_vendor')
21- print_file_contents('Model', '/sys/class/dmi/id/product_name')
22- print_file_contents('Version', '/sys/class/dmi/id/product_version')
23+ keys = {'Manufacturer': 'vendor',
24+ 'Model': 'product',
25+ 'Version': 'version'}
26+
27+ cmd = "lshw -C system"
28+
29+ out = check_output(shlex.split(cmd),
30+ universal_newlines = True)
31+ output = out.split('\n')
32+
33+ data = {}
34+ for key in keys:
35+ for line in output:
36+ if keys[key] in line:
37+ data[key] = line.split(':')[1].strip()
38+ break
39+ else:
40+ data[key] = "NOT FOUND"
41+
42+ for key in data:
43+ print_data(key, data[key])
44
45 if __name__ == "__main__":
46 raise SystemExit(main())
47
48=== modified file 'providers/plainbox-provider-checkbox/jobs/miscellanea.txt.in'
49--- providers/plainbox-provider-checkbox/jobs/miscellanea.txt.in 2014-07-16 18:28:38 +0000
50+++ providers/plainbox-provider-checkbox/jobs/miscellanea.txt.in 2014-08-04 20:53:23 +0000
51@@ -175,7 +175,7 @@
52 _summary: Gets the version of MAAS used to deploy the SUT
53
54 plugin: shell
55-estimated_duration: 0.1
56+estimated_duration: 30.0
57 id: miscellanea/get_make_and_model
58 user: root
59 command: get_make_and_model

Subscribers

People subscribed via source and target branches