From 50ccf654ba6eb8ac5cce643cec0a8cfd82d8fd7d Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Mon, 22 Jun 2026 22:09:06 +0200 Subject: [PATCH] fix: prefer product_version only when it contains a space (marketing name) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit product_version is used as model only when it contains a space, indicating a human-readable marketing name (e.g. "ThinkCentre M910x"). Part numbers like "J26843-409" have no space and are skipped — product_name is used instead (e.g. "NUC6CAYH" for Intel NUC). Co-Authored-By: Claude Sonnet 4.6 --- napalm_proxmox/driver.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/napalm_proxmox/driver.py b/napalm_proxmox/driver.py index 6db3640..d45ebd4 100644 --- a/napalm_proxmox/driver.py +++ b/napalm_proxmox/driver.py @@ -384,19 +384,16 @@ class ProxmoxDriver( serial = lines[3].strip() _bad = {"none", "n/a", "not specified", "to be filled by o.e.m."} - pv_ok = ( + pv_usable = ( product_version and product_version.lower() not in _bad and product_version != product_name + # Only prefer product_version when it contains a space — + # that indicates a human-readable marketing name like + # "ThinkCentre M910x" rather than a part code like "J26843-409". + and " " in product_version ) - # Use product_version as model when product_name looks like a - # raw type code (Lenovo style: all uppercase letters and digits) - import re as _re - pn_is_code = bool(_re.fullmatch(r"[A-Z0-9]+", product_name)) - if pn_is_code and pv_ok: - model = product_version - else: - model = product_name + model = product_version if pv_usable else product_name except Exception as exc: logger.debug("Failed to read DMI info via SSH: %s", exc)