chore: adopt the NAPALM driver standard #3

Merged
christianmanivong merged 4 commits from chore/driver-standard into main 2026-10-23 09:36:20 +00:00
2 changed files with 11 additions and 5 deletions
Showing only changes of commit 01b2a2ae58 - Show all commits

No files matched your search

+9 -4
View File
@@ -8,14 +8,19 @@ sensors, the power state and the system event log, and switches the server's pow
from __future__ import annotations
import logging
from typing import Any
from napalm.base.exceptions import ConnectionException
from napalm_device_types import HealthMetricsMixin, ManagementControllerDriver
from napalm_device_types.models import POWER_ACTIONS
from pyghmi.exceptions import IpmiException
from pyghmi.ipmi.command import Command
from pyghmi.ipmi.private.session import Session
# IPMI is this driver's protocol: the fallback for BMCs without Redfish (see above).
from pyghmi.exceptions import IpmiException # nosec B415
from pyghmi.ipmi.command import Command # nosec B415
from pyghmi.ipmi.private.session import Session # nosec B415
LOG = logging.getLogger(__name__)
_JsonDict = dict[str, Any]
@@ -93,7 +98,7 @@ class IpmiDriver(HealthMetricsMixin, ManagementControllerDriver):
try:
ipmi.ipmi_session.logout()
except Exception: # a session left open times out on the BMC
pass
LOG.debug("%s: ignored", self.hostname, exc_info=True)
self._forget_session()
def _forget_session(self) -> None:
+2 -1
View File
@@ -35,7 +35,8 @@ def to_napalm_users(accounts: Iterable[Mapping[str, Any] | None]) -> dict[str, d
continue
users[acc["username"]] = {
"level": ROLE_LEVELS.get(acc.get("role_id") or "", 0),
"password": "",
# NAPALM's get_users field; Redfish never returns a password, so it stays empty.
"password": "", # nosec B105
"sshkeys": [],
}
return users