summaryrefslogtreecommitdiff
path: root/bin/dmitest
diff options
authorJeff Lane <jeffrey.lane@canonical.com>2017-04-05 17:13:55 -0400
committerJeff Lane <jeffrey.lane@canonical.com>2017-04-05 17:13:55 -0400
commit2f138ff99865cf372c5fa9f2f9a4593af42028f9 (patch)
tree630a2a5b1bbab9c4c426bd93aa8756879f39553b /bin/dmitest
parentaf7c972ea51e8ddcfbd800b5e1d640d809c697e8 (diff)
bin/dmitest: Modified output to make it easier to read during review LP: #1680217
Diffstat (limited to 'bin/dmitest')
-rwxr-xr-xbin/dmitest89
1 files changed, 50 insertions, 39 deletions
diff --git a/bin/dmitest b/bin/dmitest
index 9be70be..58d2f60 100755
--- a/bin/dmitest
+++ b/bin/dmitest
@@ -49,7 +49,7 @@ import sys
from argparse import ArgumentParser
-def find_in_section(stream, section, label, strings, find_empty):
+def find_in_section(stream, dmi_data, section, label, strings, find_empty):
"""Search for a set of strings on a line in the output.
:param stream:
@@ -75,8 +75,8 @@ def find_in_section(stream, section, label, strings, find_empty):
if line == section:
start_looking = True
if start_looking and re.search(label, line):
- print("\n" + section)
- print(line.strip())
+ line_items = line.strip().split(':')
+ dmi_data[section][line_items[0]] = line_items[1]
empty = len(line.strip()) == len(label)
if empty and find_empty:
found = True
@@ -89,7 +89,7 @@ def find_in_section(stream, section, label, strings, find_empty):
return found
-def standard_tests(args, stream):
+def standard_tests(args, stream, dmi_data):
"""
Perform the standard set of tests.
@@ -113,58 +113,58 @@ def standard_tests(args, stream):
error.
"""
if args.test_type == 'server':
- if not find_in_section(stream, 'Chassis Information', 'Type:',
+ if not find_in_section(stream, dmi_data, 'Chassis Information', 'Type:',
['server', 'rack mount', 'blade', 'other',
'expansion chassis', 'multi-system', 'tower'],
False):
- print("*** Incorrect or unknown server chassis type!")
+ dmi_data['Chassis Information']['Type'] += " *** Incorrect or unknown server chassis type!"
retval += 1
- if find_in_section(stream, 'Base Board Information', 'Type:',
+ if find_in_section(stream, dmi_data, 'Base Board Information', 'Type:',
['portable', 'notebook', 'space-saving',
'all in one'], False):
- print("*** Incorrect server base board type!")
+ dmi_data['Base Board Information']['Type'] += " *** Incorrect server base board type!"
retval += 1
else:
- if not find_in_section(stream, 'Chassis Information', 'Type:',
+ if not find_in_section(stream, dmi_data, 'Chassis Information', 'Type:',
['notebook', 'portable', 'laptop', 'desktop',
'lunch box', 'space-saving', 'tower',
'all in one', 'hand held'], False):
- print("*** Incorrect or unknown desktop chassis type!")
+ dmi_data['Chassis Information']['Type'] += " *** Incorrect or unknown desktop chassis type!"
retval += 1
- if find_in_section(stream, 'Base Board Information', 'Type:',
+ if find_in_section(stream, dmi_data, 'Base Board Information', 'Type:',
['rack mount', 'server', 'multi-system',
'interconnect board'], False):
- print("*** Incorrect desktop base board type!")
+ dmi_data['Base Board Information']['Type'] += " *** Incorrect desktop base board type!"
retval += 1
- if find_in_section(stream, 'Chassis Information', 'Manufacturer:',
+ if find_in_section(stream, dmi_data, 'Chassis Information', 'Manufacturer:',
['empty', 'chassis manufacture', 'null', 'insyde',
'to be filled by o\.e\.m\.', 'no enclosure',
'\.\.\.\.\.'], True):
- print("*** Invalid chassis manufacturer!")
+ dmi_data['Chassis Information']['Manufacturer'] += " *** Invalid chassis manufacturer!"
retval += 1
- if find_in_section(stream, 'System Information', 'Manufacturer:',
+ if find_in_section(stream, dmi_data, 'System Information', 'Manufacturer:',
['system manufacture', 'insyde', 'standard',
'to be filled by o\.e\.m\.', 'no enclosure'], True):
- print("*** Invalid system manufacturer!")
+ dmi_data['System Information']['Manufacturer'] += " *** Invalid system manufacturer!"
retval += 1
- if find_in_section(stream, 'Base Board Information', 'Manufacturer:',
+ if find_in_section(stream, dmi_data, 'Base Board Information', 'Manufacturer:',
['to be filled by o\.e\.m\.'], True):
- print("*** Invalid base board manufacturer!")
+ dmi_data['Base Board Information']['Manufacturer'] += " *** Invalid base board manufacturer!"
retval += 1
- if find_in_section(stream, 'System Information', 'Product Name:',
+ if find_in_section(stream, dmi_data, 'System Information', 'Product Name:',
['system product name', 'to be filled by o\.e\.m\.'],
False):
- print("*** Invalid system product name!")
+ dmi_data['System Information']['Product Name'] += " *** Invalid system product name!"
retval += 1
- if find_in_section(stream, 'Base Board Information', 'Product Name:',
+ if find_in_section(stream, dmi_data, 'Base Board Information', 'Product Name:',
['base board product name',
'to be filled by o\.e\.m\.'], False):
- print("*** Invalid base board product name!")
+ dmi_data['Base Board Information']['Product Name'] += " *** Invalid base board product name!"
retval += 1
return retval
-def version_tests(args, stream):
+def version_tests(args, stream, dmi_data):
"""
Perform the version tests.
@@ -176,26 +176,26 @@ def version_tests(args, stream):
Number of problems found
"""
retval = 0
- if find_in_section(stream, 'Chassis Information', 'Version:',
+ if find_in_section(stream, dmi_data, 'Chassis Information', 'Version:',
['to be filled by o\.e\.m\.', 'empty'],
False):
- print("*** Invalid chassis version!")
+ dmi_data['Chassis Information']['Version'] += " *** Invalid chassis version!"
retval += 1
- if find_in_section(stream, 'System Information', 'Version:',
+ if find_in_section(stream, dmi_data, 'System Information', 'Version:',
['to be filled by o\.e\.m\.', '\(none\)',
'null', 'system version', 'not applicable',
'\.\.\.\.\.'], False):
- print("*** Invalid system information version!")
+ dmi_data['System Information']['Version'] += " *** Invalid system information version!"
retval += 1
- if find_in_section(stream, 'Base Board Information', 'Version:',
+ if find_in_section(stream, dmi_data, 'Base Board Information', 'Version:',
['base board version',
'empty', 'to be filled by o\.e\.m\.'], False):
- print("*** Invalid base board version!")
+ dmi_data['Base Board Information']['Version'] += " *** Invalid base board version!"
retval += 1
return retval
-def serial_tests(args, stream):
+def serial_tests(args, stream, dmi_data):
"""
Perform the serial number tests.
@@ -207,17 +207,17 @@ def serial_tests(args, stream):
Number of problems found
"""
retval = 0
- if find_in_section(stream, 'System Information', 'Serial Number:',
+ if find_in_section(stream, dmi_data, 'System Information', 'Serial Number:',
['to be filled by o\.e\.m\.',
'system serial number', '\.\.\.\.\.'],
False):
- print("*** Invalid system information serial number!")
+ dmi_data['System Information']['Serial Number'] += " *** Invalid system information serial number!"
retval += 1
- if find_in_section(stream, 'Base Board Information', 'Serial Number:',
+ if find_in_section(stream, dmi_data, 'Base Board Information', 'Serial Number:',
['n/a', 'base board serial number',
'to be filled by o\.e\.m\.', 'empty', '\.\.\.'],
False):
- print("*** Invalid base board serial number!")
+ dmi_data['Base Board Information']['Serial Number'] += " *** Invalid base board serial number!"
retval += 1
return retval
@@ -239,6 +239,11 @@ def main():
args = parser.parse_args()
bad_data = False
+ dmi_data = {'System Information': {},
+ 'Base Board Information': {},
+ 'Chassis Information': {},
+ 'Processor Information': {}}
+
# Command to retrieve DMI information
COMMAND = "dmidecode"
if args.dmifile:
@@ -271,20 +276,26 @@ def main():
retval = 0
if args.test_type == 'server' or args.test_type == 'desktop':
- retval += standard_tests(args, stream)
+ retval += standard_tests(args, stream, dmi_data)
if args.test_versions:
- retval += version_tests(args, stream)
+ retval += version_tests(args, stream, dmi_data)
if args.test_serials:
- retval += serial_tests(args, stream)
- if find_in_section(stream, 'Processor Information', 'Version:',
+ retval += serial_tests(args, stream, dmi_data)
+ if find_in_section(stream, dmi_data, 'Processor Information', 'Version:',
['sample', 'Genuine Intel\(R\) CPU 0000'], False):
- print("*** Invalid processor information!")
+ dmi_data['Processor Information']['Version'] += " *** Invalid processor information!"
retval += 1
# In review of dmidecode data on 10/23/2014, no conspicuous problems
# found in BIOS Information section's Vendor, Version, or Release Date
# fields. Therefore, no tests based on these fields have been written.
+ for section in sorted(dmi_data.keys()):
+ print('{}:'.format(section))
+ for item in sorted(dmi_data[section].keys()):
+ print('\t{}: {}'.format(item, dmi_data[section][item]))
+ print('\n')
+
if retval > 0:
if retval == 1:
print("\nFailed 1 test (see above)")