diff --git a/CHANGELOG.md b/CHANGELOG.md index ea29083..a599bc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 3.12 venv no longer has. ### 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' `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 diff --git a/README.md b/README.md index f5e304b..1e2afbb 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ NAPALM drivers for **FreeBSD** (`freebsd`) and **OpenBSD** (`openbsd`) hosts, 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 -(NetOrk/netork#792). +`OSDriver`, in the role `bsd` (one for both systems). Written for netOrk, which +provisions and manages BSD VMs (NetOrk/netork#792). ## Design diff --git a/napalm_bsd/base.py b/napalm_bsd/base.py index 89f9967..4300e4f 100644 --- a/napalm_bsd/base.py +++ b/napalm_bsd/base.py @@ -90,6 +90,9 @@ def render_snmpd_conf(settings: SnmpAgentSettingsDict) -> str: class BsdDriver(SnmpAgentMixin, EnsurePackageMixin, HostStatusMixin, OSDriver): """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 = "" #: A full init sequence, as on any general-purpose host. REBOOT_SETTLE_SECONDS = 90 diff --git a/tests/test_drivers.py b/tests/test_drivers.py index cb9c003..1988f8c 100644 --- a/tests/test_drivers.py +++ b/tests/test_drivers.py @@ -6,7 +6,7 @@ from pathlib import Path import pytest 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.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(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]) 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."""