2
# This file is part of Checkbox.
4
# Copyright 2008 Canonical Ltd.
6
# Checkbox is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License version 3,
8
# as published by the Free Software Foundation.
11
# Checkbox is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
21
from checkbox.lib.conversion import string_to_type
23
# See also 3.3.4.1 of the "System Management BIOS Reference Specification,
24
# Version 2.6.1" (Preliminary Standard) document, available from
25
# http://www.dmtf.org/standards/smbios.
28
("Undefined", "unknown"), # 0x00
30
("Unknown", "unknown"),
31
("Desktop", "desktop"),
32
("Low Profile Desktop", "desktop"),
33
("Pizza Box", "server"),
34
("Mini Tower", "desktop"),
36
("Portable", "laptop"),
38
("Notebook", "laptop"),
39
("Hand Held", "handheld"),
40
("Docking Station", "laptop"),
41
("All In One", "unknown"),
42
("Sub Notebook", "laptop"),
43
("Space-saving", "desktop"),
44
("Lunch Box", "unknown"),
45
("Main Server Chassis", "server"),
46
("Expansion Chassis", "unknown"),
47
("Sub Chassis", "unknown"),
48
("Bus Expansion Chassis", "unknown"),
49
("Peripheral Chassis", "unknown"),
50
("RAID Chassis", "unknown"),
51
("Rack Mount Chassis", "unknown"),
52
("Sealed-case PC", "unknown"),
53
("Multi-system", "unknown"),
54
("CompactPCI", "unknonw"),
55
("AdvancedTCA", "unknown"),
57
("Blade Enclosure", "unknown"))
59
chassis_names = tuple(c[0] for c in chassis)
60
chassis_types = tuple(c[1] for c in chassis)
61
chassis_name_to_type = dict(chassis)
76
"System Configuration Options",
80
"Physical Memory Array",
82
"32-bit Memory Error",
83
"Memory Array Mapped Address",
84
"Memory Device Mapped Address",
85
"Built-in Pointing Device",
89
"System Power Controls",
93
"Electrical Current Probe",
94
"Out-of-band Remote Access",
95
"Boot Integrity Services",
97
"64-bit Memory Error",
99
"Management Device Component",
100
"Management Device Threshold Data",
114
_product_blacklist = (
121
"System Product Name",
122
"To be filled by O.E.M.",
123
"To Be Filled By O.E.M.",
124
"To Be Filled By O.E.M. by More String",
130
_vendor_blacklist = (
135
"System manufacturer",
136
"System Manufacturer",
138
"To be filled by O.E.M.",
139
"To Be Filled By O.E.M.",
140
"To Be Filled By O.E.M. by More String",
141
"Unknow", # XXX This is correct mispelling
144
_serial_blacklist = (
147
"00 00 00 00 00 00 00 00",
149
"Base Board Serial Number",
150
"Chassis Serial Number",
157
"System Serial Number",
159
_version_blacklist = (
173
def __init__(self, attributes, category):
174
self._attributes = attributes
175
self.category = category
179
path = "/devices/virtual/dmi/id"
180
return os.path.join(path, self.category.lower())
184
if self.category == "CHASSIS":
185
type_string = self._attributes.get("chassis_type", "0")
187
type_index = int(type_string)
188
return Dmi.chassis_names[type_index]
192
for name in "name", "version":
193
attribute = "%s_%s" % (self.category.lower(), name)
194
product = self._attributes.get(attribute)
195
if product and product not in self._product_blacklist:
202
for name in "manufacturer", "vendor":
203
attribute = "%s_%s" % (self.category.lower(), name)
204
vendor = self._attributes.get(attribute)
205
if vendor and vendor not in self._vendor_blacklist:
212
attribute = "%s_serial" % self.category.lower()
213
serial = self._attributes.get(attribute)
214
if serial and serial not in self._serial_blacklist:
221
attribute = "%s_version" % self.category.lower()
222
version = self._attributes.get(attribute)
223
if version and version not in self._version_blacklist:
230
attribute = "%s_size" % self.category.lower()
231
size = self._attributes.get(attribute)
234
size = string_to_type(size)
240
attribute = "%s_form" % self.category.lower()
241
return self._attributes.get(attribute)