feat(scheduled-jobs): ScheduledJobsMixin and its POSIX implementation (#86)
driver / standard (pull_request) Successful in 20s
driver / lint (pull_request) Successful in 23s
driver / types (pull_request) Successful in 1m16s
driver / test (3.13) (pull_request) Successful in 1m18s
driver / test (3.12) (pull_request) Successful in 1m27s
driver / lowest (pull_request) Successful in 46s
driver / build (pull_request) Successful in 43s
driver / security (pull_request) Successful in 1m27s
CI / driver (pull_request) Successful in 3m11s
driver / publish (pull_request) Skipped

What a host runs on its own schedule as one shape: cron lines, run-parts
scripts, anacron, systemd timers, periodic, a platform's own jobs, Windows
tasks. Every job says who owns its definition and what the driver can do
to it; every write names the digest the caller saw and is refused when the
host's definition changed since.

PosixScheduledJobsMixin reads everything in one framed report as root,
switches a cron line behind #napalm-disabled:, a timer by systemctl and a
run-parts script by its execute bit, runs a job now bounded by timeout, and
writes an application's job as a timer where systemd runs, else in
/etc/cron.d or the user's crontab. napalm_device_types.cron parses cron
expressions, gives their next runs and writes them as OnCalendar lines.

get_cron_jobs and CronJobDict go: nothing called them.

Version 4.26.0, so drivers can require it before the release is tagged.

Closes #86
This commit is contained in:
christianmanivong committed 2026-11-03 05:29:27 +01:00
1 parent fdf2f89115
commit f573fa53d2
16 files changed
+2440 -44

No files matched your search

+23
View File
@@ -7,6 +7,29 @@ recorded here; their history is the git log.
## [Unreleased]
### Added
- `ScheduledJobsMixin`: what a host runs on its own schedule as one shape,
`ScheduledJobDict` — cron lines, run-parts scripts, anacron, systemd timers, `periodic`,
a platform's own jobs, Windows tasks — with who owns each definition (`managed_by`) and
what the driver can do to it (`actions`). `get_scheduled_jobs` reads them with the host's
time zone; `manage_scheduled_job` enables, disables or runs one now; `put_scheduled_job`
and `delete_scheduled_job` create, change and delete a job an application writes. Every
write names the `digest` the caller saw (`job_digest`) and raises `ScheduledJobChanged`
when the host's definition differs; `ScheduledJobRefused` for a job that cannot take a
verb (NetOrk/netork#1933, #86).
- `PosixScheduledJobsMixin`: the implementation over the command channel. One framed report
as root reads `/etc/crontab`, `/etc/cron.d`, the user crontabs, the run-parts directories,
`/etc/anacrontab` and every systemd timer with the unit it starts, and which package owns
each definition. A cron line is switched off behind `#napalm-disabled: `; an
application's job is a timer where systemd runs, else a file in `/etc/cron.d` or marked
lines in the user's crontab.
- `napalm_device_types.cron`: cron expressions as Vixie cron reads them, their next runs in
a time zone, and as systemd `OnCalendar` lines that fire on exactly the same minutes.
### Removed
- `OSDriver.get_cron_jobs` and `CronJobDict`. No application called them; the readers in
napalm-linux and napalm-bsd go with them. `get_scheduled_jobs` replaces them.
## [4.25.0] - 2026-11-02
### Added