fix: search all lines for HP banner, not just first line

Old ProCurve show version starts with "Image stamp:" — the HP product
banner (e.g. "HP J9298A Switch 2520G-8-PoE") appears on a later line.
Scan all lines and use the first HP/HPE/Aruba banner found.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Christian Manivong
2026-06-22 23:40:44 +02:00
co-authored by Claude Sonnet 4.6
parent ff37f3c59f
commit 55fe8b28f9
+9 -6
View File
@@ -199,13 +199,16 @@ def parse_model_from_version(output: str) -> tuple[str, str]:
Returns ("", "") when the first line is not an HP/Aruba device banner Returns ("", "") when the first line is not an HP/Aruba device banner
(e.g. when show version starts with "Image stamp:" on newer Aruba). (e.g. when show version starts with "Image stamp:" on newer Aruba).
""" """
first = output.strip().splitlines()[0] if output.strip() else "" # Find the HP/Aruba product banner line — may not be the first line
if not first: # (older ProCurve shows "Image stamp:" first, banner follows later)
return "", "" banner = ""
for line in output.splitlines():
# Only process lines that start with an HP/Aruba product banner if re.match(r"\s*(?:HP|HPE|Aruba)\b", line, re.I):
if not re.match(r"\s*(?:HP|HPE|Aruba)\b", first, re.I): banner = line.strip()
break
if not banner:
return "", "" return "", ""
first = banner
# Extract J-code part number # Extract J-code part number
_PN_RE_V = re.compile(r"\b(J\d{4}[A-Z]{1,2})\b") _PN_RE_V = re.compile(r"\b(J\d{4}[A-Z]{1,2})\b")