fix: report FreeBSD and OpenBSD hosts in the role bsd

BsdDriver set no ROLE, so both drivers inherited OSDriver's "linux"
and an application that shows or branches on the role treated a BSD
host as a Linux one. One key for both systems.

Closes #10
This commit is contained in:
Christian Manivong committed 2026-11-01 22:12:14 +01:00
1 parent 405239d5df
commit ce4a677756
4 files changed
+16 -3

No files matched your search

+4
View File
@@ -26,6 +26,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3.12 venv no longer has. 3.12 venv no longer has.
### Fixed ### Fixed
- FreeBSD and OpenBSD hosts are in the role `bsd`, one key for both (#10). They
inherited `OSDriver`'s `linux`, so an application that shows or branches on the
role treated them as Linux hosts. An application that keys on `linux` for every
general-purpose host has to accept `bsd` as well.
- `get_arp_table()` reports an unknown age as `-1.0` (napalm-device-types' - `get_arp_table()` reports an unknown age as `-1.0` (napalm-device-types'
`ARP_AGE_UNKNOWN`). It reported the time until the entry *expires* (FreeBSD's `ARP_AGE_UNKNOWN`). It reported the time until the entry *expires* (FreeBSD's
`expires in N seconds`, OpenBSD's `Expire` column), which is no age: an entry `expires in N seconds`, OpenBSD's `Expire` column), which is no age: an entry
+2 -2
View File
@@ -2,8 +2,8 @@
NAPALM drivers for **FreeBSD** (`freebsd`) and **OpenBSD** (`openbsd`) hosts, NAPALM drivers for **FreeBSD** (`freebsd`) and **OpenBSD** (`openbsd`) hosts,
over SSH, built on [napalm-device-types](https://git.netork.io/NAPALM/napalm-device-types)' over SSH, built on [napalm-device-types](https://git.netork.io/NAPALM/napalm-device-types)'
`OSDriver`. Written for netOrk, which provisions and manages BSD VMs `OSDriver`, in the role `bsd` (one for both systems). Written for netOrk, which
(NetOrk/netork#792). provisions and manages BSD VMs (NetOrk/netork#792).
## Design ## Design
+3
View File
@@ -90,6 +90,9 @@ def render_snmpd_conf(settings: SnmpAgentSettingsDict) -> str:
class BsdDriver(SnmpAgentMixin, EnsurePackageMixin, HostStatusMixin, OSDriver): class BsdDriver(SnmpAgentMixin, EnsurePackageMixin, HostStatusMixin, OSDriver):
"""Base for the BSD drivers; a concrete one names the commands that differ.""" """Base for the BSD drivers; a concrete one names the commands that differ."""
#: One role for FreeBSD and OpenBSD. It replaces OSDriver's "linux", which
#: would have the application treat a BSD host as a Linux one (#10).
ROLE = "bsd"
VENDOR = "" VENDOR = ""
#: A full init sequence, as on any general-purpose host. #: A full init sequence, as on any general-purpose host.
REBOOT_SETTLE_SECONDS = 90 REBOOT_SETTLE_SECONDS = 90
+7 -1
View File
@@ -6,7 +6,7 @@ from pathlib import Path
import pytest import pytest
from napalm.base import NetworkDriver from napalm.base import NetworkDriver
from napalm_device_types import OSDriver from napalm_device_types import OSDriver, primary_role_of, role_keys_of
from napalm_bsd import FreeBSDDriver, OpenBSDDriver, base from napalm_bsd import FreeBSDDriver, OpenBSDDriver, base
from napalm_bsd.base import BsdDriver from napalm_bsd.base import BsdDriver
@@ -106,6 +106,12 @@ class TestIdentity:
assert getattr(cls, getter) is not getattr(NetworkDriver, getter, None) assert getattr(cls, getter) is not getattr(NetworkDriver, getter, None)
assert getattr(cls, getter) is not getattr(OSDriver, getter, None) assert getattr(cls, getter) is not getattr(OSDriver, getter, None)
@pytest.mark.parametrize("cls", [FreeBSDDriver, OpenBSDDriver])
def test_the_role_is_bsd_not_linux(self, cls):
"""One key for both BSDs (#10); OSDriver's inherited "linux" would call them Linux."""
assert role_keys_of(cls) == ["bsd"]
assert primary_role_of(cls) == "bsd"
@pytest.mark.parametrize("cls", [FreeBSDDriver, OpenBSDDriver]) @pytest.mark.parametrize("cls", [FreeBSDDriver, OpenBSDDriver])
def test_leaves_napalms_get_users_alone(self, cls): def test_leaves_napalms_get_users_alone(self, cls):
"""NAPALM's get_users is a different getter; the host's accounts are get_os_users.""" """NAPALM's get_users is a different getter; the host's accounts are get_os_users."""