apply_updates(packages, *, log=None) on FreeBSD and OpenBSD, in a new strict module napalm_bsd/updates.py (BsdUpdatesMixin, mixed into BsdDriver). The commands come over from the application unchanged:
FreeBSD: env ASSUME_ALWAYS_YES=yes pkg upgrade -y [packages], then for a classic base freebsd-update --not-running-from-cron install of what updatesready says is fetched (exit 2 = nothing, no failure). pkgbase (FreeBSD-base repository) has no extra step.
OpenBSD: pkg_add -u -I [packages], then syspatch, run again when it exits 2 after updating itself; a second 2 is "nothing left" and no failure.
The base system runs after the packages when base-system is chosen or nothing is; chosen packages alone leave it alone.
The whole upgrade runs as root as one sh script on an exec channel, with stdout and stderr merged. The sudo password goes on stdin only, and the script starts with exec </dev/null (#8). A root login also runs the script in sh, never in a csh login shell. log receives each line as the host prints it, and output holds all of it. The exit status decides success. A host that prints nothing for 300 s, or a connection that drops, is a failure that keeps what was printed until then. A name that is not a package name raises ValueError before anything is sent.
get_host_status already has its FreeBSD branch (napalm-device-types 4.1, freebsd-version -k vs -r); nothing to add.
Tests: tests/test_apply_updates.py (commands per OS and choice, sudo/root handling, streaming split across chunks, exit status, timeout, dropped connection, the log keyword). The output samples are illustrative lines; no recorded upgrade output from a real host was taken for this PR.
Before merge (coordinator):
log is declared by napalm-device-types on feature/ap-dhcp-contracts-695 (commit 059d97f6de229d05bc705bc57bb26520967544b5, to be released as 4.54.0). CI pre-installs that commit for now (pre-install in .gitea/workflows/ci.yml). Before merging, drop the pre-install and raise the floor in pyproject.toml to napalm-device-types>=4.54.0. The driver needs nothing from 4.54.0 at runtime, so the floor is about the contract, not imports.
Version 0.6.0 (release commit included). It also releases what was already under [Unreleased] since 0.5.0. If feature/host-shutdown-2841 merges first, I merge main into this branch and move its entries under 0.6.0.
Closes #13. Part of NetOrk/netork#1105; the application side is NetOrk/netork#1112 (branch `refactor/bsd-updates-driver-1112`).
`apply_updates(packages, *, log=None)` on FreeBSD and OpenBSD, in a new strict module `napalm_bsd/updates.py` (`BsdUpdatesMixin`, mixed into `BsdDriver`). The commands come over from the application unchanged:
- FreeBSD: `env ASSUME_ALWAYS_YES=yes pkg upgrade -y [packages]`, then for a classic base `freebsd-update --not-running-from-cron install` of what `updatesready` says is fetched (exit 2 = nothing, no failure). pkgbase (`FreeBSD-base` repository) has no extra step.
- OpenBSD: `pkg_add -u -I [packages]`, then `syspatch`, run again when it exits 2 after updating itself; a second 2 is "nothing left" and no failure.
- The base system runs after the packages when `base-system` is chosen or nothing is; chosen packages alone leave it alone.
The whole upgrade runs as root as one `sh` script on an exec channel, with stdout and stderr merged. The sudo password goes on stdin only, and the script starts with `exec </dev/null` (#8). A root login also runs the script in `sh`, never in a csh login shell. `log` receives each line as the host prints it, and `output` holds all of it. The exit status decides `success`. A host that prints nothing for 300 s, or a connection that drops, is a failure that keeps what was printed until then. A name that is not a package name raises `ValueError` before anything is sent.
`get_host_status` already has its FreeBSD branch (napalm-device-types 4.1, `freebsd-version -k` vs `-r`); nothing to add.
Tests: `tests/test_apply_updates.py` (commands per OS and choice, sudo/root handling, streaming split across chunks, exit status, timeout, dropped connection, the `log` keyword). The output samples are illustrative lines; no recorded upgrade output from a real host was taken for this PR.
**Before merge (coordinator):**
- `log` is declared by napalm-device-types on `feature/ap-dhcp-contracts-695` (commit 059d97f6de229d05bc705bc57bb26520967544b5, to be released as 4.54.0). CI pre-installs that commit for now (`pre-install` in `.gitea/workflows/ci.yml`). Before merging, drop the `pre-install` and raise the floor in `pyproject.toml` to `napalm-device-types>=4.54.0`. The driver needs nothing from 4.54.0 at runtime, so the floor is about the contract, not imports.
- Version 0.6.0 (release commit included). It also releases what was already under [Unreleased] since 0.5.0. If `feature/host-shutdown-2841` merges first, I merge main into this branch and move its entries under 0.6.0.
The upgrade commands move here from the application (NetOrk/netork#1112):
pkg upgrade or pkg_add -u for the chosen packages or every one, then the
base system's patches when base-system is chosen or nothing is. A classic
FreeBSD base installs what freebsd-update fetched (nothing fetched is no
failure; pkgbase needs no extra step); OpenBSD runs syspatch again when it
updated itself, and a second exit 2 is "nothing left".
The whole upgrade runs as root as one sh script on an exec channel, stderr
merged, the sudo password on stdin only and the script's stdin closed. The
log keyword napalm-device-types declares on apply_updates receives each line
as the host prints it. A host silent for 300 s, or a dropped connection, is
a failure with what was printed until then.
CI pre-installs napalm-device-types' branch commit with that declaration
until 4.54.0 is on PyPI.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Closes #13. Part of NetOrk/netork#1105; the application side is NetOrk/netork#1112 (branch
refactor/bsd-updates-driver-1112).apply_updates(packages, *, log=None)on FreeBSD and OpenBSD, in a new strict modulenapalm_bsd/updates.py(BsdUpdatesMixin, mixed intoBsdDriver). The commands come over from the application unchanged:env ASSUME_ALWAYS_YES=yes pkg upgrade -y [packages], then for a classic basefreebsd-update --not-running-from-cron installof whatupdatesreadysays is fetched (exit 2 = nothing, no failure). pkgbase (FreeBSD-baserepository) has no extra step.pkg_add -u -I [packages], thensyspatch, run again when it exits 2 after updating itself; a second 2 is "nothing left" and no failure.base-systemis chosen or nothing is; chosen packages alone leave it alone.The whole upgrade runs as root as one
shscript on an exec channel, with stdout and stderr merged. The sudo password goes on stdin only, and the script starts withexec </dev/null(#8). A root login also runs the script insh, never in a csh login shell.logreceives each line as the host prints it, andoutputholds all of it. The exit status decidessuccess. A host that prints nothing for 300 s, or a connection that drops, is a failure that keeps what was printed until then. A name that is not a package name raisesValueErrorbefore anything is sent.get_host_statusalready has its FreeBSD branch (napalm-device-types 4.1,freebsd-version -kvs-r); nothing to add.Tests:
tests/test_apply_updates.py(commands per OS and choice, sudo/root handling, streaming split across chunks, exit status, timeout, dropped connection, thelogkeyword). The output samples are illustrative lines; no recorded upgrade output from a real host was taken for this PR.Before merge (coordinator):
logis declared by napalm-device-types onfeature/ap-dhcp-contracts-695(commit 059d97f6de229d05bc705bc57bb26520967544b5, to be released as 4.54.0). CI pre-installs that commit for now (pre-installin.gitea/workflows/ci.yml). Before merging, drop thepre-installand raise the floor inpyproject.tomltonapalm-device-types>=4.54.0. The driver needs nothing from 4.54.0 at runtime, so the floor is about the contract, not imports.feature/host-shutdown-2841merges first, I merge main into this branch and move its entries under 0.6.0.