SYS_CLASS_DMI = "/sys/class/dmi/id"
SECRET_ID_FILE = "/etc/fireinfo-id"
+INVALID_ID_STRINGS = (
+ "OEM", "O.E.M.", "o.e.m.",
+ "N/A", "n/a",
+)
+
class Singleton(type):
def __init__(cls, name, bases, dict):
super(Singleton, cls).__init__(name, bases, dict)
# Virtual machines (for example) and some boards have a UUID
# which is globally unique.
for file in ("product_uuid", "product_serial", "chassis_serial"):
- id = read_from_file(os.path.join(SYS_CLASS_DMI, file)) or ""
- ids.append(id)
+ id = read_from_file(os.path.join(SYS_CLASS_DMI, file))
+ ids.append(self.__validate_string(id))
# Use serial number from root disk (if available)
root_disk_serial = self.root_disk_serial
# As last resort, we use the UUID from pakfire.
if not ids:
- id = read_from_file("/opt/pakfire/db/uuid") or ""
+ id = read_from_file("/opt/pakfire/db/uuid")
ids.append(id)
+ # Sort out all bogous or invalid strings from the list.
+ _ids = []
+ for id in ids:
+ for i in INVALID_ID_STRINGS:
+ if i in s:
+ s = None
+ break
+
+ if id:
+ _ids.append(id)
+
+ ids = _ids
+
return "#".join(ids)
@property