OPNsense writes sshd_config from config.xml (<system><ssh>), set on the
legacy Administration page; no API controller reads or writes that
section (26.1, 26.7, master). The driver cannot harden the SSH server,
so it declares, as data, the page and the field of each algorithm list:
SSH_SETTINGS_MENU and SSH_SETTINGS_FIELDS, keyed like device-types'
SSH_ALGORITHM_CLASSES. An application tells a person what to set there.
The CARP master check moves to virtual_ips, next to the CARP reader, so
opnsense.py stays under its line ratchet.
Refs NetOrk/netork#1769
OPNsense keeps its cron jobs in its configuration and runs each as a
configd action, so the POSIX implementation does not fit: the driver has
no shell, and a job's command is not a shell line. The cron API reads and
writes them instead.
get_scheduled_jobs reads every job in one request (/api/cron/settings/get,
which carries the selected action rather than its display text). A job
another component registered is platform, one written by
put_scheduled_job carries the napalm-scheduled-job marker in its
description and is application, the rest admin. Every job can be enabled
and disabled; only an application's job is edited or deleted.
put_scheduled_job takes a configd action as command and refuses one
configd does not offer; get_scheduled_job_commands lists them. Running a
job now is refused: the API cannot run a configd action. Every write
reads the job again and refuses one whose digest changed.
Parameters are written one per line and only without blanks, quotes or
backslashes: OPNsense up to 26.1 splits them as a shell would, 26.7 takes
a line per argument, and only such arguments mean the same to both.
Requires napalm-device-types 4.26.0.
Closes#43
create_dhcp_reservation and _kea_subnet_uuid_for each walked the
searchSubnet rows for the one holding an address. Both now call the
pure subnet_containing(), which brings create_dhcp_reservation under
the complexity limit and back below its recorded length after #40;
the quality baseline records the shrunk entries.
test_open_raises_connection_exception_on_error called open() on
"unreachable.invalid" unpatched, so the unit test resolved the name
through the host's resolver and depended on it failing fast. Patch
requests.Session.get to refuse the connection and check that open()
raises ConnectionException and leaves no session behind.
Closes#41
create_dhcp_reservation searched for an existing reservation so a retry
updates it, but a failed search was logged at debug level and the add
went ahead: a write based on a read that did not happen. Raise a
RuntimeError naming searchReservation before anything is written.
Closes#40
_detect_active_dns caught every error from /api/core/service/search and
returned None, so get_dns_entries() reported a transient API error as an
empty list (no DNS service) and sync_dns_zone() blamed the DNS service.
Let the request error propagate; None only when the list was read and
neither Unbound nor Dnsmasq runs.
Closes#39
create_dhcp_reservation and delete_dhcp_reservation_and_lease looked a
reservation up by its address alone. A reservation another MAC held for
the address, made by hand or left from an earlier host, was overwritten
on create and removed on delete, together with that host's lease.
Create now raises instead of taking it over, and delete leaves another
MAC's reservation and lease in place and names that MAC in the new
reservation_other_mac field. The matching lives in kea_reservations, a
module under strict typing.
Closes#26
The Unbound and Dnsmasq override reads logged any error and returned an
empty list. sync_dns_zone took that for "no overrides": it deleted
nothing and added every record again, so a transient API error left
each record twice on the firewall. The reads now raise, which stops the
sync before it writes and lets get_dns_entries callers tell a failed
read from an empty one.
Closes#14
is_alive always opened port 443 on the hostname, so a firewall whose API
is reached through base_url on another port (https://fw:8443) read as
dead. The probe now takes host and port from base_url, falling back to
the scheme's default port.
Closes#15
_write_snmp_agent_config came out at complexity 11 and failed the
standard job. The community check and the listen address now live in
their own helpers; the baseline follows the file's new length.
The configure step posted contact, location, sysobjid and bindip, and
listen in the shape get returns. OPNsense 26.x refuses a field its model
does not have with HTTP 500, so the setup failed on every current box.
It now sends syscontact/syslocation, listen as a string, and contact and
location only when the caller gives them: an empty one would have blanked
the operator's.
get_arp_table and get_ipv6_neighbors_table reported expires, the seconds
left until the entry expires: an entry refreshed a second ago looked 20
minutes old. Both now report ARP_AGE_UNKNOWN (-1.0).
NetOrk/netork#1327
netOrk runs every driver in its own containers on Python 3.12, so 3.10
and 3.11 are no longer supported or tested. requires-python, mypy and
ruff move to 3.12, along with what ruff's pyupgrade rules then rewrite.
get_vpn_tunnels() grew past the quality baseline with the key fix. The
WireGuard part is pure parsing of /api/wireguard/service/show, like the
listen ports in listening.py, so it moves to wireguard.py and the driver
calls it. opnsense.py shrinks from 3125 to 3082 lines.
get_vpn_tunnels() keyed WireGuard peers with a running counter over the
peer rows, so a peer added ahead of an existing one renumbered every peer
after it. Whatever a consumer stores per key moved with it: netOrk's site
link and tunnel check ended up on a new, offline peer and alarmed while the
real tunnel was up.
The key is now the interface and the start of the public key, as in
napalm-linux, made URL-safe because the key is a path segment. Two peers
sharing the prefix get the whole key; a row without a public key keeps its
position. IPsec and OpenVPN keys were already stable.
Every WireGuard key changes once; netOrk carries its
per-tunnel metadata across (netork#1654).
- CI moves to .gitea/workflows/ci.yml and calls the shared driver workflow
of NAPALM/driver-standard; .github/ is gone.
- setuptools>=77 with the SPDX license string, no License classifier,
Python 3.10-3.13 classifiers, napalm-device-types>=4.21.1, a dev extra
with floors, links to git.netork.io, LICENSE file, py.typed.
- CHANGELOG.md in Keep-a-Changelog form; README names Python 3.10, the
Gitea clone URL and the new CI.
- mypy strict for the package; exempt for now (52 errors): ha, listening,
opnsense, ospf_mixin, ping_mixin, port_forwards, resolver_mixin.
Recorded in the quality baseline with the long and complex functions,
the 3100-line opnsense.py and one unannotated public method.
- Coverage floor 79 % (measured 79.20 %).
- The module logger and the refresh constants of opnsense.py move below
the imports (E402).
- Two long result messages are wrapped in parentheses (E501).
- nosec for the two wildcard addresses (B104): one is the address
sockstat reports for "*", the other a route's gateway compared with
0.0.0.0. Neither binds a socket; both are false positives.
Mechanical: ruff format, and ruff check --fix with the rule set every NAPALM
driver uses (E, F, I, UP, B at line length 100, Python 3.10). What ruff
cannot fix comes in the next commit.
When Kea, ISC DHCP and the ARP fallback all failed, get_dhcp_leases()
returned [], which a caller cannot tell from a server with no leases. It now
raises a RuntimeError naming each failure, and returns [] only when a source
answered with nothing. An empty ARP table after both lease sources failed
counts as unread too, since ARP rows are no lease data.
Closes#27
create_dhcp_reservation rewrote an existing reservation and called
service/reconfigure even when it already held exactly what was asked, e.g.
on a retried provisioning job. reconfigure stops and starts Kea (the Kea
service controller keeps reconfigureForceRestart() = true and configd has no
reload action), which once left a firewall without DHCP. A reservation whose
subnet, MAC (normalised), IP, hostname and description already match is now
left alone.
Refs NetOrk/netork#1187
netOrk reached these through the private _get/_post (netOrk #1113); they
are napalm-device-types 4.17's contracts now:
- apply_updates passes the packages it is given (it dropped them) and
get_update_progress reports the upgrade's state and log.
- get_dns_forwards, set_dns_forward (an existing forward of the domain
is changed, not doubled) and remove_dns_forward, each applied with a
reconfigure; a refusal is raised.
- get_ospf translates FRR's diagnostics into neutral terms.
Requires napalm-device-types 4.17.0.
updates_available came from the cached firmware status with ten package
names; netOrk builds it from get_available_updates with the full list
(netOrk #1111).
fix_snmp enabled os-net-snmp with community "public", contact
netork@localhost and location "Managed by netOrk", and added a
floating pass rule for UDP/161 from any source on every interface: a
firewall managed over WAN answered its SNMP tree to anyone there (#13).
The driver implements napalm-device-types 4.13's configure_snmp_agent
steps instead:
- install: os-net-snmp only when missing (a reinstall resets it);
- configure: community, contact, location and listen address from the
caller; a DNS name is not a listen address; a refused save fails;
- firewall: one floating pass rule per allowed source, the old
any-source rule and rules of an earlier run replaced, operators'
rules untouched; no sources, no change;
- start: restart net-snmp.
The hand-built UDP probe goes; the caller asks the agent itself.
BREAKING CHANGE: run_device_action is removed. Requires
napalm-device-types 4.13.
Closes#13
get_facts read hostname and version from /api/core/system/status, which on
OPNsense 26.7 carries neither: every firewall read as nameless and "unknown",
and netOrk kept naming one by its address. /api/diagnostics/system/system_information
has both (name is the FQDN, versions[0] "OPNsense 26.7.7-amd64"). The status
answer still counts where the new one gives nothing.
get_interfaces_ip listed each interface's primary address only, so a CARP address
never showed as the holder's. It now lists an address bound to a VHID on the node
that is MASTER for it, and leaves it off a BACKUP -- as keepalived puts the address
on the master alone. netOrk's VIP badge sits on that interface (netOrk #1121).
get_dhcp_ha reads kea/dhcpv4/get (the ha section) and
kea/dhcpv4/searchPeer: whether Kea's HA hook is on, this firewall's peer
name -- the % twin when left at its default -- and each peer's name,
role and HA URL. get_config_sync reads core/hasync/get: the address this
firewall pushes its configuration to and the ticked sync items, mapped to
the service names get_services reports; items that are no service stay
under `unmapped`. Both raise when the request fails.
Configuration, not state: Kea's control agent, which knows whether the
pair is in hot standby right now, listens on localhost only.
Needs napalm-device-types 4.11.0 (ConfigSyncMixin). NetOrk/netork#1125.
The records netOrk sends include what its poll read off the same
firewall, hand-made host overrides among them. sync_dns_zone deletes only
tagged overrides and then added every record again under the tag, so each
hand-made override ended up on the device twice (NetOrk/netork#1123).
An enabled, untagged override with the same name, type and address in the
zone now stands in for its record. A copy made earlier is tagged, so the
next sync deletes it and does not add it again.
carp_virtual_ip() and its state table moved here from napalm-device-types
(4.10.1, NAPALM/napalm-device-types#39): under the agreed structure the base
package carries only the shape of the reading, and what a CARP state means is
protocol knowledge. Tests moved along (test_carp_states.py).
get_virtual_ips() reads every address bound to a CARP VHID -- the CARP
address and IP aliases on its VHID alike -- from
/api/interfaces/overview/export, with this node's CARP state, so the reading
says who holds each address. interfaces/vip_settings would list the same
addresses with each VHID's CARP password; it is not read.
vip_manager and keepalived are Linux mechanisms and are None here. Needs
napalm-device-types 4.10.0 (carp_virtual_ip).
netOrk #1121.