fix: prefer product_version only when it contains a space (marketing name)
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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
d9b3ac12ea
commit
50ccf654ba
@@ -384,19 +384,16 @@ class ProxmoxDriver(
|
|||||||
serial = lines[3].strip()
|
serial = lines[3].strip()
|
||||||
|
|
||||||
_bad = {"none", "n/a", "not specified", "to be filled by o.e.m."}
|
_bad = {"none", "n/a", "not specified", "to be filled by o.e.m."}
|
||||||
pv_ok = (
|
pv_usable = (
|
||||||
product_version
|
product_version
|
||||||
and product_version.lower() not in _bad
|
and product_version.lower() not in _bad
|
||||||
and product_version != product_name
|
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
|
model = product_version if pv_usable else product_name
|
||||||
# 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
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.debug("Failed to read DMI info via SSH: %s", exc)
|
logger.debug("Failed to read DMI info via SSH: %s", exc)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user