110
118
shipped in those form factors, so we don't flag that combination as an
113
if args.test_type == 'server':
121
if args.system_type == 'server':
114
122
if not find_in_section(stream, 'Chassis Information', 'Type:',
115
123
['server', 'rack mount', 'blade',
116
124
'expansion chassis', 'multi-system'], False):
117
125
print("*** Incorrect or unknown server chassis type!")
119
127
if find_in_section(stream, 'Base Board Information', 'Type:',
120
128
['portable', 'notebook', 'space-saving',
121
129
'all in one'], False):
122
130
print("*** Incorrect server base board type!")
125
133
if not find_in_section(stream, 'Chassis Information', 'Type:',
126
134
['notebook', 'portable', 'laptop', 'desktop',
127
135
'lunch box', 'space-saving', 'tower',
128
136
'all in one', 'hand held'], False):
129
137
print("*** Incorrect or unknown desktop chassis type!")
131
139
if find_in_section(stream, 'Base Board Information', 'Type:',
132
140
['rack mount', 'server', 'multi-system',
133
141
'interconnect board'], False):
134
142
print("*** Incorrect desktop base board type!")
136
145
if find_in_section(stream, 'Chassis Information', 'Manufacturer:',
137
146
['empty', 'chassis manufacture', 'null', 'insyde',
138
147
'to be filled by o\.e\.m\.', 'no enclosure',
139
148
'\.\.\.\.\.'], True):
140
149
print("*** Invalid chassis manufacturer!")
142
152
if find_in_section(stream, 'System Information', 'Manufacturer:',
143
153
['system manufacture', 'insyde', 'standard',
144
154
'to be filled by o\.e\.m\.', 'no enclosure'], True):
145
155
print("*** Invalid system manufacturer!")
147
158
if find_in_section(stream, 'Base Board Information', 'Manufacturer:',
148
159
['to be filled by o\.e\.m\.'], True):
149
160
print("*** Invalid base board manufacturer!")
151
163
if find_in_section(stream, 'System Information', 'Product Name:',
152
164
['system product name', 'to be filled by o\.e\.m\.'],
154
166
print("*** Invalid system product name!")
156
169
if find_in_section(stream, 'Base Board Information', 'Product Name:',
157
170
['base board product name',
158
171
'to be filled by o\.e\.m\.'], False):
159
172
print("*** Invalid base board product name!")
164
def version_tests(args, stream):
166
Perform the version tests.
169
Arguments passed to script
171
Input stream containing dmidecode output
173
Number of problems found
176
if find_in_section(stream, 'Chassis Information', 'Version:',
177
['to be filled by o\.e\.m\.', 'empty'],
179
print("*** Invalid chassis version!")
181
if find_in_section(stream, 'System Information', 'Version:',
182
['to be filled by o\.e\.m\.', '\(none\)',
183
'null', 'system version', 'not applicable',
184
'\.\.\.\.\.'], False):
185
print("*** Invalid system information version!")
187
if find_in_section(stream, 'Base Board Information', 'Version:',
188
['base board version',
189
'empty', 'to be filled by o\.e\.m\.'], False):
190
print("*** Invalid base board version!")
195
def serial_tests(args, stream):
197
Perform the serial number tests.
200
Arguments passed to script
202
Input stream containing dmidecode output
204
Number of problems found
207
if find_in_section(stream, 'System Information', 'Serial Number:',
208
['to be filled by o\.e\.m\.',
209
'system serial number', '\.\.\.\.\.'],
211
print("*** Invalid system information serial number!")
213
if find_in_section(stream, 'Base Board Information', 'Serial Number:',
214
['n/a', 'base board serial number',
215
'to be filled by o\.e\.m\.', 'empty', '\.\.\.'],
217
print("*** Invalid base board serial number!")
224
parser = ArgumentParser("dmitest")
225
parser.add_argument('test_type',
226
help="Test type ('server', 'desktop' or 'cpu-check').",
227
choices=['server', 'desktop', 'cpu-check'])
228
parser.add_argument('--dmifile',
229
help="File to use in lieu of dmidecode.")
230
parser.add_argument('--test_versions', action="store_true",
231
help="Set to check version information")
232
parser.add_argument('--test_serials', action="store_true",
233
help="Set to check serial number information")
234
args = parser.parse_args()
236
# Command to retrieve DMI information
237
COMMAND = "dmidecode"
240
print("Reading " + args.dmifile + " as DMI data")
241
stream = subprocess.check_output(['cat', args.dmifile],
242
universal_newlines=True).splitlines()
244
stream = subprocess.check_output(COMMAND,
245
universal_newlines=True).splitlines()
246
except subprocess.CalledProcessError as err:
247
print("Error running {}: {}".format(COMMAND, err))
251
if args.test_type == 'server' or args.test_type == 'desktop':
252
retval += standard_tests(args, stream)
253
175
if args.test_versions:
254
retval += version_tests(args, stream)
177
if find_in_section(stream, 'Chassis Information', 'Version:',
178
['to be filled by o\.e\.m\.', 'empty'],
180
print("*** Invalid chassis version!")
183
if find_in_section(stream, 'System Information', 'Version:',
184
['to be filled by o\.e\.m\.', '\(none\)',
185
'null', 'system version', 'not applicable',
186
'\.\.\.\.\.'], False):
187
print("*** Invalid system information version!")
190
if find_in_section(stream, 'Base Board Information', 'Version:',
191
['base board version',
192
'empty', 'to be filled by o\.e\.m\.'], False):
193
print("*** Invalid base board version!")
255
196
if args.test_serials:
256
retval += serial_tests(args, stream)
198
if find_in_section(stream, 'System Information', 'Serial Number:',
199
['to be filled by o\.e\.m\.',
200
'system serial number', '\.\.\.\.\.'],
202
print("*** Invalid system information serial number!")
205
if find_in_section(stream, 'Base Board Information', 'Serial Number:',
206
['n/a', 'base board serial number',
207
'to be filled by o\.e\.m\.', 'empty', '\.\.\.'],
209
print("*** Invalid base board serial number!")
257
212
if find_in_section(stream, 'Processor Information', 'Version:',
258
213
['sample'], False):
259
214
print("*** Invalid processor information!")
262
217
# In review of dmidecode data on 10/23/2014, no conspicuous problems
263
218
# found in BIOS Information section's Vendor, Version, or Release Date
264
219
# fields. Therefore, no tests based on these fields have been written.
268
print("\nFailed 1 test (see above)")
270
print("\nFailed {0} tests (see above)".format(retval))
222
print("\nFailed one or more tests (see above)")
272
224
print("\nPassed all tests")