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.
The driver accepted any SSH host key. It now verifies through
napalm-device-types' HostKeyCheck (>= 4.19.0): with a known key in
optional_args["ssh_host_keys"] any other key is refused before login, and
every key seen is reported to optional_args["ssh_host_key_observer"].
Without either argument it connects as before (first use).
fix_snmp wrote an application's snmpd.conf (community public, Managed
by netOrk, netork@localhost) and judged itself by a local snmpget.
The drivers implement napalm-device-types 4.13's SnmpAgentMixin steps
instead: net-snmp installed, snmpd.conf with one rocommunity line per
allowed source (staged without privilege, installed by root), snmpd
enabled and restarted. pf and ipfw rules stay the operator's. A
community or text that would break the file is refused. The caller
verifies with its own SNMP client.
Also get_management_peer() from SSH_CONNECTION, ensure_package from
the base package, and get_snmp_config no longer assumes "public".
BREAKING CHANGE: run_device_action is removed. Requires
napalm-device-types 4.13.
Part of #12 (the OpenBSD new_version text is still open).
run_command prepended the sudo password to the caller's stdin. A sudo
that does not prompt left it for the command, and fix_snmp's
'cat > snmpd.conf' wrote it as the configuration's first line before
making the file world-readable.
run_command now refuses stdin to a privileged command while a sudo
password is set. fix_snmp stages the configuration in a mktemp file
without privilege, and root installs it next to the target and renames
it over, so nothing root runs follows a symlink.
Closes#8
napalm-device-types 4.7 renamed OSDriver.get_users to get_os_users:
NAPALM's own get_users has another shape and a stub on every driver, so
hasattr could not tell the two apart. BsdDriver now implements
get_os_users with the same return shape and leaves NAPALM's get_users
alone.
Require napalm-device-types>=4.7.1 and bump the version to 0.2.0.
FreeBSDDriver (`freebsd`) and OpenBSDDriver (`openbsd`) on a shared
BsdDriver, for the BSD VMs netOrk provisions and BSD hosts added by hand
(NetOrk/netork#798).
- SSH over exec channels (napalm-device-types' run_on_transport): no PTY,
stdout and stderr apart, real exit codes; run_command()/open_stream()
are public. Root through `sudo -S` with the password on stdin, or
`sudo -n` without one.
- Facts: hostname, release and running kernel (freebsd-version / uname),
hardware from SMBIOS (kenv) or hw.* sysctls, uptime from kern.boottime.
- Interfaces and addresses (ifconfig -a: ether/lladdr, hex netmasks,
scoped IPv6), routes (netstat -rn, OpenBSD's abbreviated networks
written out, host/broadcast/loopback entries left out), ARP (FreeBSD's
sentences, OpenBSD's table), users and groups, processes (lstart read as
one five-word field), cron jobs (system crontab and the login user's).
- Parsers are pure functions, tested on output recorded from FreeBSD 15.1
(hand-installed and cloud image) and OpenBSD 7.9 (NetOrk/netork#793),
with internal addresses replaced by documentation ranges.