OpenMediaVault writes several cron files itself, from its own database, and writes them again on every apply: an edit napalm-linux made there would be taken back without a word. So every file OMV generates (/etc/cron.d/openmediavault-*, the mail-queue flush, apticron and the recycle-bin cleanup) is platform and only runs; the inherited writers refuse it. The web UI's "Scheduled Jobs" and the power-management schedule live in conf.system.cron.job. They are read through Cron.getList, disabled ones included, instead of the lines OMV generates for them, and switched with Cron.set, run with Cron.execute (followed through Exec.getOutput), made with Cron.set and removed with Cron.delete. An application's job on OMV is an OMV job, visible in its web UI, marked by its comment. Each write applies the cron module alone, so changes pending in the web UI for other modules stay pending. Every other job keeps napalm-linux's behaviour. Requires napalm-device-types 4.26.0 and napalm-linux 0.16.0. Closes #18
3.8 KiB
napalm-openmediavault
NAPALM driver for OpenMediaVault NAS systems, built on
napalm-device-types (StorageDriver) and
napalm-linux (LinuxDriver).
OpenMediaVault is Debian underneath, so the driver inherits everything napalm-linux does for a Linux host (packages, updates, services, users, processes, scheduled jobs, Docker) and adds the NAS side: disks, md RAID arrays, filesystems, shares and the NAS services.
Tested against
| Model | Firmware |
|---|---|
| OpenMediaVault | 6.x (Debian Bullseye), 7.x (Debian Bookworm) |
Connection
SSH, port 22 by default, through napalm-linux (Netmiko). The account needs a shell; smartctl
and mdadm run through sudo (passwordless, or with sudo_password). Every optional_args
key of napalm-linux is accepted (port, pkg_manager, sudo_password, …).
from napalm import get_network_driver
driver = get_network_driver("openmediavault")
with driver("192.0.2.10", "admin", "secret", optional_args={"sudo_password": "secret"}) as nas:
print(nas.get_facts())
print(nas.get_disks())
print(nas.get_shares())
Supported
| Getter / action | |
|---|---|
get_facts |
napalm-linux's facts, os_version is OMV <version> of the openmediavault package |
get_disks |
lsblk for the disks, smartctl -iHA for health (healthy, warning, failed, unknown), temperature and RPM |
get_disk_pools |
md arrays from /proc/mdstat, size and state from mdadm --detail |
get_volumes |
mounted block-device filesystems from df, read-only flag from /proc/mounts |
get_shares |
SMB, NFS and FTP shares from OMV's configuration database (omv-confdbadm) |
get_storage_services |
whether smbd, nfs-server, proftpd, ssh and rsync are enabled and running |
get_scheduled_jobs |
napalm-linux's reading of the host, but the web UI's "Scheduled Jobs" and the power-management schedule come from Cron.getList (omv:<uuid>, disabled ones too) instead of the lines OMV generates for them; the cron files OMV generates (/etc/cron.d/openmediavault-*, openmediavault-flushmailq, -apticron, -samba-recycle) are platform and only run |
manage_scheduled_job |
an OMV job: Cron.set with only enable changed, or Cron.execute followed through Exec.getOutput (stopped after 300 s); a power-management job is not run; anything else as napalm-linux, never a generated file |
put_scheduled_job |
an OMV job through Cron.set, in the web UI like any other, its comment napalm-scheduled-job: <name> <description>; a multi-line command is fine |
delete_scheduled_job |
an application's OMV job through Cron.delete; an application's Linux job as napalm-linux |
| everything of napalm-linux | packages, updates, services, users, processes, Docker, … |
Every scheduled-job write through RPC deploys the cron module alone (Config.applyChanges):
changes left pending in the web UI for other modules stay pending.
"Upgrade everything" is a full upgrade (FULL_UPGRADE = True): a plain apt-get upgrade holds
back OpenMediaVault's own packages and the kernel.
Not supported
get_volume_snapshots,get_replication_jobs,get_quotasraiseNotImplementedError.harden_ssh_serveris not offered: OpenMediaVault generatessshd_configfrom its own database and would undo a drop-in on the next apply of its SSH settings.- Configuration changes to shares, disks or arrays.
Installation
pip install napalm-openmediavault
Development
The rules are in STANDARDS.md.
python -m venv .venv && .venv/bin/pip install -e ".[dev]"
.venv/bin/pytest --cov
License
Apache-2.0