chore: adopt the NAPALM driver standard #3
No files matched your search
@@ -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:
|
||||
|
||||
@@ -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
|
||||
Reference in new issue
Block a user