16
16
# You should have received a copy of the GNU General Public License
17
17
# along with Checkbox. If not, see <http://www.gnu.org/licenses/>.
20
22
# See also 3.3.4.1 of the "System Management BIOS Reference Specification,
21
23
# Version 2.6.1" (Preliminary Standard) document, available from
22
24
# http://www.dmtf.org/standards/smbios.
25
("Undefined", "unknown"), # 0x00
27
("Undefined", "unknown"), # 0x00
26
28
("Other", "unknown"),
27
29
("Unknown", "unknown"),
28
30
("Desktop", "desktop"),
53
55
("Blade", "server"),
54
56
("Blade Enclosure", "unknown"))
56
chassis_names = [c[0] for c in chassis]
57
chassis_types = [c[1] for c in chassis]
58
chassis_names = tuple(c[0] for c in chassis)
59
chassis_types = tuple(c[1] for c in chassis)
58
60
chassis_name_to_type = dict(chassis)
61
class DmiNotAvailable(object):
62
def __init__(self, function):
63
self._function = function
65
def __get__(self, instance, cls=None):
66
self._instance = instance
69
def __call__(self, *args, **kwargs):
70
name = self._function(self._instance, *args, **kwargs)
71
if name == "Not Available":
75
"System Configuration Options",
79
"Physical Memory Array",
81
"32-bit Memory Error",
82
"Memory Array Mapped Address",
83
"Memory Device Mapped Address",
84
"Built-in Pointing Device",
88
"System Power Controls",
92
"Electrical Current Probe",
93
"Out-of-band Remote Access",
94
"Boot Integrity Services",
96
"64-bit Memory Error",
98
"Management Device Component",
99
"Management Device Threshold Data",
113
_product_blacklist = (
120
"System Product Name",
121
"To be filled by O.E.M.",
122
"To Be Filled By O.E.M.",
123
"To Be Filled By O.E.M. by More String",
129
_vendor_blacklist = (
134
"System manufacturer",
135
"System Manufacturer",
137
"To be filled by O.E.M.",
138
"To Be Filled By O.E.M.",
139
"To Be Filled By O.E.M. by More String",
140
"Unknow", # XXX This is correct mispelling
143
_serial_blacklist = (
146
"00 00 00 00 00 00 00 00",
148
"Base Board Serial Number",
149
"Chassis Serial Number",
156
"System Serial Number",
158
_version_blacklist = (
172
def __init__(self, attributes, category):
173
self._attributes = attributes
174
self.category = category
178
path = "/devices/virtual/dmi/id"
179
return os.path.join(path, self.category.lower())
183
if self.category == "CHASSIS":
184
type_string = self._attributes.get("chassis_type", "0")
186
type_index = int(type_string)
187
return Dmi.chassis_names[type_index]
191
for name in "name", "version":
192
attribute = "%s_%s" % (self.category.lower(), name)
193
product = self._attributes.get(attribute)
194
if product and product not in self._product_blacklist:
201
for name in "manufacturer", "vendor":
202
attribute = "%s_%s" % (self.category.lower(), name)
203
vendor = self._attributes.get(attribute)
204
if vendor and vendor not in self._vendor_blacklist:
211
attribute = "%s_serial" % self.category.lower()
212
serial = self._attributes.get(attribute)
213
if serial and serial not in self._serial_blacklist:
220
attribute = "%s_version" % self.category.lower()
221
version = self._attributes.get(attribute)
222
if version and version not in self._version_blacklist: