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:
co-authored by
Claude Sonnet 4.6
parent
ff37f3c59f
commit
55fe8b28f9
@@ -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
|
||||
(e.g. when show version starts with "Image stamp:" on newer Aruba).
|
||||
"""
|
||||
first = output.strip().splitlines()[0] if output.strip() else ""
|
||||
if not first:
|
||||
return "", ""
|
||||
|
||||
# Only process lines that start with an HP/Aruba product banner
|
||||
if not re.match(r"\s*(?:HP|HPE|Aruba)\b", first, re.I):
|
||||
# Find the HP/Aruba product banner line — may not be the first line
|
||||
# (older ProCurve shows "Image stamp:" first, banner follows later)
|
||||
banner = ""
|
||||
for line in output.splitlines():
|
||||
if re.match(r"\s*(?:HP|HPE|Aruba)\b", line, re.I):
|
||||
banner = line.strip()
|
||||
break
|
||||
if not banner:
|
||||
return "", ""
|
||||
first = banner
|
||||
|
||||
# Extract J-code part number
|
||||
_PN_RE_V = re.compile(r"\b(J\d{4}[A-Z]{1,2})\b")
|
||||
|
||||
Reference in New Issue
Block a user