From 87db7b28730acad8ef495f9212d193b6102d8138 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Mon, 29 Jun 2026 12:36:09 +0200 Subject: [PATCH] fix(get_config): SSH fallback when REST API returns empty (HP 2530/YA firmware) HP 2530 switches with YA firmware do not expose /rest/v7/running-config. _get_config_via_ssh() opens a temporary netmiko session to run 'show running-config' as fallback when the API endpoint returns 404. --- napalm_procurve/procurve.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/napalm_procurve/procurve.py b/napalm_procurve/procurve.py index 69a1a90..3a8ff5f 100644 --- a/napalm_procurve/procurve.py +++ b/napalm_procurve/procurve.py @@ -565,7 +565,13 @@ class ProcurveDriver(ConfigLifecycleMixin, SwitchDriver): ) -> Dict[str, str]: """Return device configuration.""" if self._transport == "api": - return self._api.get_config() + result = self._api.get_config() + if result.get("running"): + return result + # REST endpoint not available on this firmware (e.g. HP 2530 / YA series). + # Fall back to a temporary SSH connection to run show running-config. + running = self._get_config_via_ssh() + return {"running": running, "startup": "", "candidate": ""} running = "" startup = "" @@ -580,6 +586,22 @@ class ProcurveDriver(ConfigLifecycleMixin, SwitchDriver): return {"running": running, "startup": startup, "candidate": candidate} + def _get_config_via_ssh(self) -> str: + """Open a one-shot SSH session to retrieve running-config. + + Used as fallback when the REST API does not expose the config endpoint + (e.g. HP 2530 / YA firmware). Returns empty string on any failure. + """ + try: + conn = ConnectHandler(**self._netmiko_kwargs()) + try: + return conn.send_command("show running-config") + finally: + conn.disconnect() + except Exception as exc: + logger.warning("SSH config fallback failed for %s: %s", self.hostname, exc) + return "" + # ------------------------------------------------------------------ # NAPALM: get_environment # ------------------------------------------------------------------