fix: prefer product_version over product_name for DMI model name
On Lenovo (and some other vendors) product_name contains the machine-type code (e.g. "10MYS03U00") while product_version holds the marketing name (e.g. "ThinkCentre M910x"). Read both and prefer product_version when it is set and different from product_name. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
9631275d6b
commit
a3b0414d99
@@ -356,23 +356,38 @@ class ProxmoxDriver(
|
||||
release = version.get("release", "")
|
||||
os_version = f"Proxmox VE {pve_version}" if pve_version else f"Proxmox VE {release}"
|
||||
|
||||
# Physical hardware info from Linux DMI sysfs
|
||||
# Physical hardware info from Linux DMI sysfs.
|
||||
# product_version often contains the marketing name (e.g. "ThinkCentre M910x")
|
||||
# while product_name holds the machine-type code (e.g. "10MYS03U00").
|
||||
# We prefer product_version when it is set and not identical to product_name.
|
||||
vendor = ""
|
||||
model = ""
|
||||
serial = ""
|
||||
try:
|
||||
dmi_cmd = (
|
||||
"printf '%s\\t%s\\t%s' "
|
||||
"printf '%s\\t%s\\t%s\\t%s' "
|
||||
"\"$(cat /sys/class/dmi/id/sys_vendor 2>/dev/null)\" "
|
||||
"\"$(cat /sys/class/dmi/id/product_name 2>/dev/null)\" "
|
||||
"\"$(cat /sys/class/dmi/id/product_version 2>/dev/null)\" "
|
||||
"\"$(cat /sys/class/dmi/id/product_serial 2>/dev/null)\""
|
||||
)
|
||||
raw = self._exec_ssh_command(dmi_cmd).strip()
|
||||
parts = raw.split("\t")
|
||||
if len(parts) >= 3:
|
||||
if len(parts) >= 4:
|
||||
vendor = parts[0].strip()
|
||||
model = parts[1].strip()
|
||||
serial = parts[2].strip()
|
||||
product_name = parts[1].strip()
|
||||
product_version = parts[2].strip()
|
||||
serial = parts[3].strip()
|
||||
# Prefer product_version (marketing name) over product_name (type code)
|
||||
# unless it is empty, "None", or identical to product_name.
|
||||
if (
|
||||
product_version
|
||||
and product_version.lower() not in ("none", "n/a", "not specified")
|
||||
and product_version != product_name
|
||||
):
|
||||
model = product_version
|
||||
else:
|
||||
model = product_name
|
||||
except Exception as exc:
|
||||
logger.debug("Failed to read DMI info via SSH: %s", exc)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user