diff --git a/napalm_proxmox/driver.py b/napalm_proxmox/driver.py index 64a058c..4c5dfc2 100644 --- a/napalm_proxmox/driver.py +++ b/napalm_proxmox/driver.py @@ -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)