Use manufacturer from NocoDB to select correct Netmiko device type

Aruba/HP switches now connect with hp_procurve instead of cisco_ios,
fixing the 'terminal width 511' failure. Manufacturer is read from
NocoDB and mapped to the correct device type before SSH connect.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-13 17:38:22 +00:00
parent 93afa9192b
commit 237c45ddfc
2 changed files with 28 additions and 8 deletions
+26 -6
View File
@@ -26,9 +26,18 @@ _pt.Transport.auth_password = _auth_password_no_fallback
_login_lock = threading.Semaphore(1)
def connect_and_query(ip, login_delay=3):
def _device_type_for(manufacturer: str) -> str:
m = (manufacturer or "").lower()
if any(k in m for k in ("aruba", "hp", "hewlett", "procurve")):
return "hp_procurve"
if "dell" in m:
return "dell_os10"
return DEVICE_TYPE
def connect_and_query(ip, login_delay=3, device_type=None):
device = {
"device_type": DEVICE_TYPE,
"device_type": device_type or DEVICE_TYPE,
"host": ip,
"username": SSH_USERNAME,
"password": SSH_PASSWORD,
@@ -194,14 +203,25 @@ def _aruba_firmware(version_output):
# ── Scan orchestration ────────────────────────────────────────────────────────
def scan_all_switches(ip_list, progress_callback=None, max_workers=5, login_delay=3):
def scan_all_switches(switch_list, progress_callback=None, max_workers=5, login_delay=3):
"""switch_list: list of IP strings or dicts with 'ip' and optional 'manufacturer'."""
results = []
total = len(ip_list)
total = len(switch_list)
done = 0
_scan = partial(connect_and_query, login_delay=login_delay)
def _submit(entry):
if isinstance(entry, dict):
ip = entry["ip"]
dt = _device_type_for(entry.get("manufacturer", ""))
else:
ip, dt = entry, None
return ip, executor.submit(connect_and_query, ip, login_delay=login_delay, device_type=dt)
with ThreadPoolExecutor(max_workers=max_workers) as executor:
future_to_ip = {executor.submit(_scan, ip): ip for ip in ip_list}
future_to_ip = {}
for entry in switch_list:
ip, fut = _submit(entry)
future_to_ip[fut] = ip
for future in as_completed(future_to_ip):
ip = future_to_ip[future]