summaryrefslogtreecommitdiff
path: root/bin
diff options
authorJeff Lane <jeffrey.lane@canonical.com>2017-03-14 13:10:07 -0400
committerSylvain Pineau <sylvain.pineau@canonical.com>2017-04-03 09:39:22 +0200
commit5584978f6852044e56e57f7acdae4539a29ff95e (patch)
treed704e1fe52d6f84192b5ee5e2db46708a71dd33f /bin
parent67c98cf02c9356d14a2a87f3791386aed500fb38 (diff)
bin/get_make_and_model: Now also reveals make/model info for the mainboard to assist in identifying whitebox systems like those from SuperMicro LP: #1672726
Diffstat (limited to 'bin')
-rwxr-xr-xbin/get_make_and_model46
1 files changed, 27 insertions, 19 deletions
diff --git a/bin/get_make_and_model b/bin/get_make_and_model
index bb5efd9..496a949 100755
--- a/bin/get_make_and_model
+++ b/bin/get_make_and_model
@@ -4,31 +4,39 @@ import os.path
import shlex
from subprocess import check_output
+def print_header(value):
+ print("{}:".format(value))
+
def print_data(key, value):
- print("{}: {}".format(key, value))
+ print(" {}: {}".format(key, value))
+
+def run_cmd(option):
+ cmd = "lshw -C " + option
+ out = check_output(shlex.split(cmd),
+ universal_newlines = True)
+ return out.split('\n')
def main():
keys = {'Manufacturer': 'vendor',
'Model': 'product',
'Version': 'version'}
-
- cmd = "lshw -C system"
-
- out = check_output(shlex.split(cmd),
- universal_newlines = True)
- output = out.split('\n')
-
- data = {}
- for key in keys:
- for line in output:
- if keys[key] in line:
- data[key] = line.split(':')[1].strip()
- break
- else:
- data[key] = "NOT FOUND"
-
- for key in data:
- print_data(key, data[key])
+ lshw_classes = {'system': 'System',
+ 'bus': 'Mainboard'}
+
+ for lshw_class in lshw_classes:
+ output = run_cmd(lshw_class)
+ data = {}
+ for key in keys:
+ for line in output:
+ if keys[key] in line:
+ data[key] = line.split(':')[1].strip()
+ break
+ else:
+ data[key] = "NOT FOUND"
+
+ print_header(lshw_classes[lshw_class])
+ for key in data:
+ print_data(key, data[key])
if __name__ == "__main__":
raise SystemExit(main())