From 6d82fad80ad5fd1b868e6bbbb4fd320577c67f11 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Fri, 23 Oct 2026 12:04:32 +0200 Subject: [PATCH 1/4] style: ruff format and the lint rules of the driver standard 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. --- napalm_openmediavault/openmediavault.py | 79 ++++++++++++------------- pyproject.toml | 11 ++++ tests/test_omv_type_label.py | 4 +- 3 files changed, 53 insertions(+), 41 deletions(-) diff --git a/napalm_openmediavault/openmediavault.py b/napalm_openmediavault/openmediavault.py index 54b2983..509e047 100644 --- a/napalm_openmediavault/openmediavault.py +++ b/napalm_openmediavault/openmediavault.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # Licensed under the Apache License, Version 2.0 """NAPALM driver for OpenMediaVault NAS systems. @@ -22,7 +21,7 @@ import json as _json import re from typing import Any -from napalm_device_types import FingerprintRule +from napalm_device_types import FingerprintRule, StorageDriver from napalm_device_types.models import ( DiskPoolDict, LogicalVolumeDict, @@ -33,7 +32,6 @@ from napalm_device_types.models import ( StorageServiceDict, VolumeSnapshotDict, ) -from napalm_device_types import StorageDriver from napalm_linux.linux import LinuxDriver @@ -76,9 +74,7 @@ class OpenMediaVaultDriver(StorageDriver, LinuxDriver): """Return device facts, overriding OMV version from dpkg.""" facts = super().get_facts() try: - ver = self._send( - "dpkg-query -W -f='${Version}' openmediavault 2>/dev/null" - ).strip() + ver = self._send("dpkg-query -W -f='${Version}' openmediavault 2>/dev/null").strip() if ver: facts["os_version"] = f"OMV {ver}" except Exception: @@ -159,9 +155,7 @@ class OpenMediaVaultDriver(StorageDriver, LinuxDriver): rpm = 0 try: - smart = self._sudo( - f"smartctl -iA /dev/{name} 2>/dev/null", read_timeout=15 - ) + smart = self._sudo(f"smartctl -iA /dev/{name} 2>/dev/null", read_timeout=15) if "PASSED" in smart: health = "healthy" elif "FAILED" in smart: @@ -180,18 +174,20 @@ class OpenMediaVaultDriver(StorageDriver, LinuxDriver): except Exception: pass - result.append(PhysicalDiskDict( - slot=f"/dev/{name}", - model=model, - serial=serial, - vendor=vendor, - type=disk_type, - size=size, - rpm=rpm, - temperature=temperature, - health=health, - pool=self._disk_to_pool(name), - )) + result.append( + PhysicalDiskDict( + slot=f"/dev/{name}", + model=model, + serial=serial, + vendor=vendor, + type=disk_type, + size=size, + rpm=rpm, + temperature=temperature, + health=health, + pool=self._disk_to_pool(name), + ) + ) return result @@ -200,7 +196,7 @@ class OpenMediaVaultDriver(StorageDriver, LinuxDriver): try: mdstat = self._send("cat /proc/mdstat 2>/dev/null") for line in mdstat.splitlines(): - if disk_name in line and re.match(r'^md\d+', line): + if disk_name in line and re.match(r"^md\d+", line): return line.split(":")[0].strip() except Exception: pass @@ -251,19 +247,17 @@ class OpenMediaVaultDriver(StorageDriver, LinuxDriver): return result for line in mdstat.splitlines(): - m = re.match(r'^(md\d+)\s*:\s+(\S+)\s+(\S+)\s+(.*)', line) + m = re.match(r"^(md\d+)\s*:\s+(\S+)\s+(\S+)\s+(.*)", line) if not m: continue md_name, state_word, level_raw, members_raw = m.groups() - member_disks = re.findall(r'(\w+)\[\d+\]', members_raw) + member_disks = re.findall(r"(\w+)\[\d+\]", members_raw) status = "online" if state_word == "active" else "offline" total = 0 try: - detail = self._sudo( - f"mdadm --detail /dev/{md_name} 2>/dev/null", read_timeout=10 - ) + detail = self._sudo(f"mdadm --detail /dev/{md_name} 2>/dev/null", read_timeout=10) size_m = re.search(r"Array Size\s*:\s*(\d+)\s*\(", detail) if size_m: total = int(size_m.group(1)) * 1024 # kB → bytes @@ -359,10 +353,13 @@ class OpenMediaVaultDriver(StorageDriver, LinuxDriver): key = mountpoint.lstrip("/").replace("/", "-") or "root" pool = device.removeprefix("/dev/") - readonly = bool(re.search( - rf'^{re.escape(device)}\s+\S+\s+\S+\s+(?:[^,\s]*,)*ro(?:,|\s|$)', - mounts, re.MULTILINE, - )) + readonly = bool( + re.search( + rf"^{re.escape(device)}\s+\S+\s+\S+\s+(?:[^,\s]*,)*ro(?:,|\s|$)", + mounts, + re.MULTILINE, + ) + ) result[key] = LogicalVolumeDict( name=key, @@ -458,11 +455,11 @@ class OpenMediaVaultDriver(StorageDriver, LinuxDriver): """ _SVC_MAP = [ # (key, systemd unit, default port) - ("smb", "smbd", 445), - ("nfs", "nfs-server", 2049), - ("ftp", "proftpd", 21), - ("ssh", "ssh", 22), - ("rsync", "rsync", 873), + ("smb", "smbd", 445), + ("nfs", "nfs-server", 2049), + ("ftp", "proftpd", 21), + ("ssh", "ssh", 22), + ("rsync", "rsync", 873), ] result: dict[str, StorageServiceDict] = {} for key, unit, port in _SVC_MAP: @@ -478,7 +475,11 @@ class OpenMediaVaultDriver(StorageDriver, LinuxDriver): except Exception: running = enabled = False result[key] = StorageServiceDict( - name=key, enabled=enabled, running=running, port=port, version="", + name=key, + enabled=enabled, + running=running, + port=port, + version="", ) return result @@ -486,9 +487,7 @@ class OpenMediaVaultDriver(StorageDriver, LinuxDriver): def get_volume_snapshots(self, volume: str = "") -> list[VolumeSnapshotDict]: """Return volume snapshots (not supported on OpenMediaVault).""" - raise NotImplementedError( - "OpenMediaVault does not expose volume snapshots via this driver" - ) + raise NotImplementedError("OpenMediaVault does not expose volume snapshots via this driver") def get_replication_jobs(self) -> list[ReplicationJobDict]: """Return replication jobs (not supported on OpenMediaVault).""" diff --git a/pyproject.toml b/pyproject.toml index 3090a3d..1b9f787 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,6 +41,17 @@ Repository = "https://github.com/chrismanivong/napalm-openmediavault" where = ["."] include = ["napalm_openmediavault*"] +[tool.ruff] +line-length = 100 +target-version = "py310" + +[tool.ruff.lint] +select = ["E", "F", "I", "UP", "B"] + +[tool.ruff.lint.per-file-ignores] +# Recorded device output keeps its lines. +"tests/**" = ["E501"] + [tool.mypy] python_version = "3.9" strict = true diff --git a/tests/test_omv_type_label.py b/tests/test_omv_type_label.py index 0675c2a..c22d3cc 100644 --- a/tests/test_omv_type_label.py +++ b/tests/test_omv_type_label.py @@ -9,10 +9,12 @@ def test_type_label_is_storage(): def test_type_label_overrides_linux(): from napalm_linux.linux import LinuxDriver + assert LinuxDriver.TYPE_LABEL == "Linux" assert OpenMediaVaultDriver.TYPE_LABEL != LinuxDriver.TYPE_LABEL def test_storage_device_flag_removed(): - assert not hasattr(OpenMediaVaultDriver, "storage_device"), \ + assert not hasattr(OpenMediaVaultDriver, "storage_device"), ( "storage_device is superseded by TYPE_LABEL = 'Storage'" + ) -- 2.54.0 From 9fbbd1753005adddaea9a09278a0d42cab1dffe5 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Fri, 23 Oct 2026 12:05:00 +0200 Subject: [PATCH 2/4] fix: what bandit and the remaining lint rules found - The five except Exception: pass (OMV version, smartctl per disk, /proc/mdstat, mdadm --detail, shared folder lookup) now log at debug level with the module logger (B110), so a swallowed failure leaves a trace. The returned data is unchanged. - The get_storage_services docstring example is wrapped to 100 columns. --- napalm_openmediavault/openmediavault.py | 30 ++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/napalm_openmediavault/openmediavault.py b/napalm_openmediavault/openmediavault.py index 509e047..3a2e56e 100644 --- a/napalm_openmediavault/openmediavault.py +++ b/napalm_openmediavault/openmediavault.py @@ -18,6 +18,7 @@ Tested against OpenMediaVault 6.x and 7.x (Debian Bullseye / Bookworm base). from __future__ import annotations import json as _json +import logging import re from typing import Any @@ -34,6 +35,8 @@ from napalm_device_types.models import ( ) from napalm_linux.linux import LinuxDriver +logger = logging.getLogger(__name__) + class OpenMediaVaultDriver(StorageDriver, LinuxDriver): """NAPALM driver for OpenMediaVault NAS systems. @@ -78,7 +81,7 @@ class OpenMediaVaultDriver(StorageDriver, LinuxDriver): if ver: facts["os_version"] = f"OMV {ver}" except Exception: - pass + logger.debug("%s: OMV version not read: ignored", self.hostname, exc_info=True) return facts # ── Physical disks ───────────────────────────────────────────────────────── @@ -172,7 +175,7 @@ class OpenMediaVaultDriver(StorageDriver, LinuxDriver): if rpm_m: rpm = int(rpm_m.group(1)) except Exception: - pass + logger.debug("%s: smartctl for %s: ignored", self.hostname, name, exc_info=True) result.append( PhysicalDiskDict( @@ -199,7 +202,7 @@ class OpenMediaVaultDriver(StorageDriver, LinuxDriver): if disk_name in line and re.match(r"^md\d+", line): return line.split(":")[0].strip() except Exception: - pass + logger.debug("%s: /proc/mdstat not read: ignored", self.hostname, exc_info=True) return "" # ── md RAID pools ────────────────────────────────────────────────────────── @@ -266,7 +269,9 @@ class OpenMediaVaultDriver(StorageDriver, LinuxDriver): elif re.search(r"State\s*:.*(?:faulty|failed)", detail, re.IGNORECASE): status = "faulted" except Exception: - pass + logger.debug( + "%s: mdadm --detail for %s: ignored", self.hostname, md_name, exc_info=True + ) result[md_name] = DiskPoolDict( name=md_name, @@ -446,11 +451,16 @@ class OpenMediaVaultDriver(StorageDriver, LinuxDriver): Example:: { - "smb": {"name": "smb", "enabled": True, "running": True, "port": 445, "version": ""}, - "nfs": {"name": "nfs", "enabled": True, "running": True, "port": 2049, "version": ""}, - "ftp": {"name": "ftp", "enabled": False,"running": False, "port": 21, "version": ""}, - "ssh": {"name": "ssh", "enabled": True, "running": True, "port": 22, "version": ""}, - "rsync": {"name": "rsync", "enabled": False,"running": False, "port": 873, "version": ""}, + "smb": {"name": "smb", "enabled": True, "running": True, + "port": 445, "version": ""}, + "nfs": {"name": "nfs", "enabled": True, "running": True, + "port": 2049, "version": ""}, + "ftp": {"name": "ftp", "enabled": False, "running": False, + "port": 21, "version": ""}, + "ssh": {"name": "ssh", "enabled": True, "running": True, + "port": 22, "version": ""}, + "rsync": {"name": "rsync", "enabled": False, "running": False, + "port": 873, "version": ""}, } """ _SVC_MAP = [ @@ -537,7 +547,7 @@ class OpenMediaVaultDriver(StorageDriver, LinuxDriver): break return f"{mnt_dir}/{rel}".rstrip("/") if rel else mnt_dir except Exception: - pass + logger.debug("%s: shared folder %s: ignored", self.hostname, uuid, exc_info=True) return "" def _smb_shares(self) -> dict[str, NASShareDict]: -- 2.54.0 From aba36b3b11f66b1803a88a673cb916bef0ac31c5 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Fri, 23 Oct 2026 12:07:04 +0200 Subject: [PATCH 3/4] chore: adopt the NAPALM driver standard - CI moves to .gitea/workflows/ci.yml and calls the shared driver workflow of NAPALM/driver-standard; napalm-device-types and napalm-linux come from git until napalm-linux 0.15.0 is on PyPI. - requires-python >=3.10 (napalm-device-types needs it), SPDX license string, setuptools>=77, LICENSE file, py.typed, links to git.netork.io. - Dependencies: napalm-device-types>=4.22.0, napalm-linux>=0.15.0, napalm>=4.0 (tested at 4.0.0); dev extra with pytest, pytest-cov, mypy and ruff. - mypy strict for the whole package, no exempt module: _omv_read is annotated as returning list[dict[str, Any]] (types only). - Coverage floor 15 % (measured 15.89 %); the four long getters and the complexity of get_disks are recorded in the quality baseline. - README (what it is, how it connects, the getters, what it does not do) and CHANGELOG are new. - The committed egg-info and __pycache__ files are untracked; .gitignore from the template keeps them, .venv and build output out. --- .gitea/workflows/ci.yml | 17 ++ .github/workflows/ci.yml | 50 ----- .gitignore | 9 + CHANGELOG.md | 19 ++ LICENSE | 191 ++++++++++++++++++ README.md | 72 +++++++ napalm_openmediavault.egg-info/PKG-INFO | 20 -- napalm_openmediavault.egg-info/SOURCES.txt | 10 - .../dependency_links.txt | 1 - .../entry_points.txt | 2 - napalm_openmediavault.egg-info/requires.txt | 3 - napalm_openmediavault.egg-info/top_level.txt | 1 - .../__pycache__/__init__.cpython-312.pyc | Bin 880 -> 0 bytes .../openmediavault.cpython-312.pyc | Bin 25780 -> 0 bytes napalm_openmediavault/openmediavault.py | 5 +- napalm_openmediavault/py.typed | 0 pyproject.toml | 42 +++- tests/__pycache__/__init__.cpython-312.pyc | Bin 178 -> 0 bytes ...mv_type_label.cpython-312-pytest-9.0.3.pyc | Bin 4343 -> 0 bytes tests/quality_baseline.json | 15 ++ 20 files changed, 359 insertions(+), 98 deletions(-) create mode 100644 .gitea/workflows/ci.yml delete mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 LICENSE create mode 100644 README.md delete mode 100644 napalm_openmediavault.egg-info/PKG-INFO delete mode 100644 napalm_openmediavault.egg-info/SOURCES.txt delete mode 100644 napalm_openmediavault.egg-info/dependency_links.txt delete mode 100644 napalm_openmediavault.egg-info/entry_points.txt delete mode 100644 napalm_openmediavault.egg-info/requires.txt delete mode 100644 napalm_openmediavault.egg-info/top_level.txt delete mode 100644 napalm_openmediavault/__pycache__/__init__.cpython-312.pyc delete mode 100644 napalm_openmediavault/__pycache__/openmediavault.cpython-312.pyc create mode 100644 napalm_openmediavault/py.typed delete mode 100644 tests/__pycache__/__init__.cpython-312.pyc delete mode 100644 tests/__pycache__/test_omv_type_label.cpython-312-pytest-9.0.3.pyc create mode 100644 tests/quality_baseline.json diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..8a28be9 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,17 @@ +name: CI + +on: + push: + branches: [main, master] + tags: ["v*"] + pull_request: + +jobs: + driver: + uses: NAPALM/driver-standard/.gitea/workflows/driver.yml@main + with: + standard-ref: main + # Until napalm-linux 0.15.0 is on PyPI. + pre-install: "git+https://git.netork.io/NAPALM/napalm-device-types.git git+https://git.netork.io/NAPALM/napalm-linux.git" + secrets: + PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 5533e6c..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: CI - -on: - push: - branches: ["**"] - pull_request: - branches: ["**"] - -jobs: - test: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: ["3.10", "3.11", "3.12"] - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - cache: pip - - - name: Install package with dev extras - run: | - python -m pip install --upgrade pip - # napalm-device-types lives in git.netork.io/NAPALM, not on PyPI: without this - # pip looks there, finds an unrelated 0.1.0 and the job dies before any test. - python -m pip install "napalm-device-types @ git+https://git.netork.io/NAPALM/napalm-device-types.git" - # napalm-linux, which this driver builds on, is not on PyPI either. - python -m pip install "napalm-linux @ git+https://git.netork.io/NAPALM/napalm-linux.git" - python -m pip install -e ".[dev]" - - - name: Run unit tests - run: | - python -m pytest -q --tb=short - - - name: Build wheel and sdist - run: | - python -m pip install build - python -m build - - - name: Upload dist artifacts - # v4 refuses to run on Gitea ("not currently supported on GHES"). - uses: actions/upload-artifact@v3 - with: - name: dist-${{ matrix.python-version }} - path: dist/* \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a368c9d --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +__pycache__/ +*.egg-info/ +.venv/ +build/ +dist/ +.coverage +.pytest_cache/ +.mypy_cache/ +.ruff_cache/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..5912642 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,19 @@ +# Changelog + +All notable changes to this driver. The format follows +[Keep a Changelog](https://keepachangelog.com/), versions follow +[Semantic Versioning](https://semver.org/). + +## [Unreleased] + +### Changed +- The driver follows the NAPALM driver standard + (https://git.netork.io/NAPALM/driver-standard): CI on Gitea runs ruff, mypy, the + tests on Python 3.10–3.13 and at the lowest declared versions, bandit, pip-audit and + a build check, and a release tag publishes to PyPI. The package now ships `py.typed`, + a README and a LICENSE file. It needs napalm-device-types 4.22.0 and napalm-linux + 0.15.0. **Python 3.9 is no longer supported**; napalm-device-types never ran on it. +- Failures the driver deliberately ignores (the OpenMediaVault version, `smartctl` for one + disk, `/proc/mdstat`, `mdadm --detail`, a shared folder lookup) are now logged at debug + level. + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..68d39ec --- /dev/null +++ b/LICENSE @@ -0,0 +1,191 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship made available under + the License, as indicated by a copyright notice that is included in + or attached to the work (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other transformations + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean, as submitted to the Licensor for inclusion + in the Work by the copyright owner or by an individual or Legal Entity + authorized to submit on behalf of the copyright owner. For the purposes + of this definition, "submitted" means any form of electronic, verbal, + or written communication sent to the Licensor or its representatives, + including but not limited to communication on electronic mailing lists, + source code control systems, and issue tracking systems that are managed + by, or on behalf of, the Licensor for the purpose of discussing and + improving the Work, but excluding communication that is conspicuously + marked or designated in writing by the copyright owner as "Not a + Contribution." + + "Contributor" shall mean Licensor and any Legal Entity on behalf of + whom a Contribution has been received by the Licensor and incorporated + within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by the combined Contribution(s) and the Work + to which such Contribution(s) was submitted. If You institute patent + litigation against any entity (including a cross-claim or counterclaim + in a lawsuit) alleging that the Work or any Contribution embodied + within the Work constitutes direct or contributory patent infringement, + then any patent licenses granted to You under this License for that + Work shall terminate as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or Derivative + Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, You must include a readable copy of the + attribution notices contained within such NOTICE file, in + at least one of the following places: within a NOTICE text file + distributed as part of the Derivative Works; within the Source + form or documentation, if provided along with the Derivative + Works; or, within a display generated by the Derivative Works, + if and wherever such third-party notices normally appear. The + contents of the NOTICE file are for informational purposes only + and do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own license statement for Your modifications and + may provide additional grant of rights to use, copy, modify, merge, + publish, distribute, sublicense, and/or sell copies of the Work, + and to permit persons to whom the Work is furnished to do so, + subject to the following conditions: + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any conditions of TITLE, + MERCHANTIBILITY, or FITNESS FOR A PARTICULAR PURPOSE. + See the License for the specific language governing permissions and + limitations under the License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or exemplary damages of any character arising as a + result of this License or out of the use or inability to use the + Work (even if such Contributor has been advised of the possibility + of such damages). + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may offer only + conditions consistent with this License, subject to the following + additional conditions: + + (a) You may offer additional warranty, indemnity, or other liability + terms and conditions; and + + (b) You may offer support for the Work in return for a fee. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format in question. It may also be + possible to make it available with a creative commons license. + + Copyright 2026 Christian Manivong + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..b9b24ef --- /dev/null +++ b/README.md @@ -0,0 +1,72 @@ +# napalm-openmediavault + +NAPALM driver for [OpenMediaVault](https://www.openmediavault.org/) NAS systems, built on +[napalm-device-types](https://git.netork.io/NAPALM/napalm-device-types) (`StorageDriver`) and +[napalm-linux](https://git.netork.io/NAPALM/napalm-linux) (`LinuxDriver`). + +OpenMediaVault is Debian underneath, so the driver inherits everything napalm-linux does for a +Linux host (packages, updates, services, users, processes, cron, 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`, …). + +```python +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 ` of the `openmediavault` package | +| `get_disks` | `lsblk` for the disks, `smartctl -iA` for health, 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 | +| everything of napalm-linux | packages, updates, services, users, processes, cron, Docker, … | + +"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_quotas` raise `NotImplementedError`. +- `harden_ssh_server` is not offered: OpenMediaVault generates `sshd_config` from 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 + +```bash +pip install napalm-openmediavault +``` + +## Development + +The rules are in [STANDARDS.md](https://git.netork.io/NAPALM/driver-standard/src/branch/main/STANDARDS.md). + +```bash +python -m venv .venv && .venv/bin/pip install -e ".[dev]" +.venv/bin/pytest --cov +``` + +## License + +Apache-2.0 diff --git a/napalm_openmediavault.egg-info/PKG-INFO b/napalm_openmediavault.egg-info/PKG-INFO deleted file mode 100644 index 5626507..0000000 --- a/napalm_openmediavault.egg-info/PKG-INFO +++ /dev/null @@ -1,20 +0,0 @@ -Metadata-Version: 2.4 -Name: napalm-openmediavault -Version: 0.1.0 -Summary: NAPALM driver for OpenMediaVault NAS (SSH) -Author-email: Christian Manivong -License: Apache-2.0 -Project-URL: Repository, https://github.com/chrismanivong/napalm-openmediavault -Keywords: napalm,network,automation,nas,openmediavault,omv,storage -Classifier: Development Status :: 3 - Alpha -Classifier: Intended Audience :: Developers -Classifier: Intended Audience :: System Administrators -Classifier: License :: OSI Approved :: Apache Software License -Classifier: Programming Language :: Python :: 3 -Classifier: Topic :: System :: Networking -Classifier: Topic :: System :: Systems Administration -Requires-Python: >=3.9 -Description-Content-Type: text/markdown -Requires-Dist: napalm>=4.0 -Requires-Dist: napalm-device-types>=0.3.0 -Requires-Dist: napalm-linux>=0.1.0 diff --git a/napalm_openmediavault.egg-info/SOURCES.txt b/napalm_openmediavault.egg-info/SOURCES.txt deleted file mode 100644 index 059d625..0000000 --- a/napalm_openmediavault.egg-info/SOURCES.txt +++ /dev/null @@ -1,10 +0,0 @@ -pyproject.toml -napalm_openmediavault/__init__.py -napalm_openmediavault/openmediavault.py -napalm_openmediavault.egg-info/PKG-INFO -napalm_openmediavault.egg-info/SOURCES.txt -napalm_openmediavault.egg-info/dependency_links.txt -napalm_openmediavault.egg-info/entry_points.txt -napalm_openmediavault.egg-info/requires.txt -napalm_openmediavault.egg-info/top_level.txt -tests/test_omv_type_label.py \ No newline at end of file diff --git a/napalm_openmediavault.egg-info/dependency_links.txt b/napalm_openmediavault.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/napalm_openmediavault.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/napalm_openmediavault.egg-info/entry_points.txt b/napalm_openmediavault.egg-info/entry_points.txt deleted file mode 100644 index 0ff4e97..0000000 --- a/napalm_openmediavault.egg-info/entry_points.txt +++ /dev/null @@ -1,2 +0,0 @@ -[napalm.drivers] -openmediavault = napalm_openmediavault:OpenMediaVaultDriver diff --git a/napalm_openmediavault.egg-info/requires.txt b/napalm_openmediavault.egg-info/requires.txt deleted file mode 100644 index 8eb100d..0000000 --- a/napalm_openmediavault.egg-info/requires.txt +++ /dev/null @@ -1,3 +0,0 @@ -napalm>=4.0 -napalm-device-types>=0.3.0 -napalm-linux>=0.1.0 diff --git a/napalm_openmediavault.egg-info/top_level.txt b/napalm_openmediavault.egg-info/top_level.txt deleted file mode 100644 index c87b84f..0000000 --- a/napalm_openmediavault.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -napalm_openmediavault diff --git a/napalm_openmediavault/__pycache__/__init__.cpython-312.pyc b/napalm_openmediavault/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index 3077e54165dad63b8798b5ced5841f8a229d45aa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 880 zcmZuwy>1gh5WcgG5-m!X0#OZCidb^)a0&!gf@BmdA;ortA%&aO=627w5sKxJ?q}wk?`HO!xo_Dq~VG%1KTZsYM?)8A9X1 z+2C{pRP&r^h?Rzk9xw!-`b0%HhvI~O3>%prN$dpQrbJapxMj_@Y zt1EXAkrbw*7vXp~4To>ez$8R7U~(atCYCD+IVWHfR&)Z9k};nHC6-(e!(8KUjccgi zM+lt7S_!CR!gpl?E;6OcJJ9?(0lSU=movU?Jl$l6YTdiz;UOw+QOKs2;My<;B|8H1HD>x)gG5+FR7d383m?*)*DAC+lPNX1` z=St2)%JOi`>_lINZV{-`;l{nKqibUdG3Jt6jDu`>vwb8KU8L-}E`A~3UFLzi{cifc a|EIC*xBhlLf9U_X|L8kvf85gB4*UmSX&dqY diff --git a/napalm_openmediavault/__pycache__/openmediavault.cpython-312.pyc b/napalm_openmediavault/__pycache__/openmediavault.cpython-312.pyc deleted file mode 100644 index 6022e63e165df1d0dd5558f5f1548d86a1d923b3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 25780 zcmd6Q32+=&dS3Tjm>CSNIdB7PfCn%j0FvM-XeBL306fG?07XdK+gT zcHmWQ93Y^W?+K2#p97^;Z6hukb)5z=^uJnXkU;*I)-d^~634s)X8RZet< zJR#o=i&Cqh$|90UM10FI58%iI&ro`9uEzNN5aE`oQO-o(U1@g#&C;< zVu^02vrRZXHYJCLgAqXt%a?_4>GhFeVCeG$hcio!t8 z(Ow}aNx>=P8ca;cEcT9ZDL%X-D$*;KC@KcUC{mn=Ps9=-Q5XqFLQ1Vs&Pbdk5=RhW z@WjD(;bi|{J4@Do=CmM>1*MP>icLgAQZNyY$5`Ze^h(EYJT@X;q>P=1;;~q0IH8n2 zIC!K}5C$j2xDXs34#~0*mIW#F@>z_^+UI> z^D3*re%xDoLl?urm~e0+5|KkwAz_DbFdn~*+@iw8pd3POpAm8R`Al&z7K@`}QB(OO zp3Ob6Dcs8X!?DqjG%kf>iGhho$ZyZMdNGiv6RMxThMJ3jtLOst+pb|Nx)L5%@^UMs490@v@>o1U z@leMSHKszD)D{Dw4lBg3gjVIo-@St$zk(SW;)Zz4Qj^FJnMD(3rWv!+JY+L*p(4>D zTHm$Zz;vN&lpnIQw`Q?Ow7=`PVbDKi%nt$?iFIQxLI_+Y8`TmTSO1uc*L!u7k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--git a/napalm_openmediavault/openmediavault.py b/napalm_openmediavault/openmediavault.py index 3a2e56e..0b070d7 100644 --- a/napalm_openmediavault/openmediavault.py +++ b/napalm_openmediavault/openmediavault.py @@ -509,7 +509,7 @@ class OpenMediaVaultDriver(StorageDriver, LinuxDriver): # ── Internal helpers ─────────────────────────────────────────────────────── - def _omv_read(self, key: str) -> list: + def _omv_read(self, key: str) -> list[dict[str, Any]]: """Query the OMV config database and return a list of objects. Handles both OMV 6+ (returns a JSON array directly) and older @@ -525,7 +525,8 @@ class OpenMediaVaultDriver(StorageDriver, LinuxDriver): # Older OMV wraps the list: {"share": [...]} for wrapper in ("share", "rule", "entry", "mntent", "sharedfolder"): if wrapper in data and isinstance(data[wrapper], list): - return data[wrapper] + wrapped: list[dict[str, Any]] = data[wrapper] + return wrapped return [] except Exception: return [] diff --git a/napalm_openmediavault/py.typed b/napalm_openmediavault/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/pyproject.toml b/pyproject.toml index 1b9f787..02bb2ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=68", "wheel"] +requires = ["setuptools>=77"] build-backend = "setuptools.build_meta" [project] @@ -7,8 +7,8 @@ name = "napalm-openmediavault" version = "0.2.0" description = "NAPALM driver for OpenMediaVault NAS (SSH)" readme = "README.md" -requires-python = ">=3.9" -license = { text = "Apache-2.0" } +requires-python = ">=3.10" +license = "Apache-2.0" authors = [ { name = "Christian Manivong", email = "christian@manivong.de" }, ] @@ -17,30 +17,40 @@ classifiers = [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Intended Audience :: System Administrators", - "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Topic :: System :: Networking", "Topic :: System :: Systems Administration", + "Typing :: Typed", ] dependencies = [ "napalm>=4.0", - "napalm-device-types>=0.3.0", - "napalm-linux>=0.5.0", + "napalm-device-types>=4.22.0", + "napalm-linux>=0.15.0", ] [project.optional-dependencies] -dev = ["pytest"] +dev = ["pytest>=8", "pytest-cov>=5", "mypy>=1.11", "ruff>=0.6"] [project.entry-points."napalm.drivers"] openmediavault = "napalm_openmediavault:OpenMediaVaultDriver" [project.urls] -Repository = "https://github.com/chrismanivong/napalm-openmediavault" +Repository = "https://git.netork.io/NAPALM/napalm-openmediavault" +Issues = "https://git.netork.io/NAPALM/napalm-openmediavault/issues" +Changelog = "https://git.netork.io/NAPALM/napalm-openmediavault/src/branch/main/CHANGELOG.md" [tool.setuptools.packages.find] where = ["."] include = ["napalm_openmediavault*"] +[tool.setuptools.package-data] +napalm_openmediavault = ["py.typed"] + [tool.ruff] line-length = 100 target-version = "py310" @@ -53,6 +63,20 @@ select = ["E", "F", "I", "UP", "B"] "tests/**" = ["E501"] [tool.mypy] -python_version = "3.9" +python_version = "3.10" strict = true +# napalm itself is untyped, so every driver subclasses Any. +disallow_subclassing_any = false + +[[tool.mypy.overrides]] +module = ["napalm.*", "netmiko.*", "paramiko.*"] ignore_missing_imports = true + +[tool.pytest.ini_options] +testpaths = ["tests"] + +[tool.coverage.run] +source = ["napalm_openmediavault"] + +[tool.coverage.report] +fail_under = 15 diff --git a/tests/__pycache__/__init__.cpython-312.pyc b/tests/__pycache__/__init__.cpython-312.pyc deleted file mode 100644 index da365d8fdbaafe4ca689953ec3344dc3b1ca3202..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 178 zcmX@j%ge<81ph9|WP#|%AOanHW&w&!XQ*V*Wb|9fP{ah}eFmxd6{w$)pPQs!)PiIto zqxsoNZaN2j{faW(<)ne;oeWT8HDzYk2F|-Qq=mVF6wZJC@uYS3%!iX_3qiGTuI5%h zavjh9%wG1x3F57|r1&?EJ!PuVo=&f4@vV5W(9z((`Mru04TW4;6iaAJ6r}-EZK!pn zt}gWfm#U}ePhnapEM`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x#c{67=YB7i?)ZR9IgKp_%B_KT z{;~~&C`d?I%W{HQ%ZhU1JBY<8I%x4Pry`FZe9aVzdy#k{dq`g4yYpSaLsto<5C|8s_%H)HL Ts*XO$Y3ii9*_~3)sLaKG9d}!0 diff --git a/tests/quality_baseline.json b/tests/quality_baseline.json new file mode 100644 index 0000000..9f2e60f --- /dev/null +++ b/tests/quality_baseline.json @@ -0,0 +1,15 @@ +{ + "coverage_floor": 15.0, + "function_complexity": { + "napalm_openmediavault/openmediavault.py::OpenMediaVaultDriver.get_disks": 18 + }, + "function_lines": { + "napalm_openmediavault/openmediavault.py::OpenMediaVaultDriver.get_disk_pools": 81, + "napalm_openmediavault/openmediavault.py::OpenMediaVaultDriver.get_disks": 107, + "napalm_openmediavault/openmediavault.py::OpenMediaVaultDriver.get_storage_services": 58, + "napalm_openmediavault/openmediavault.py::OpenMediaVaultDriver.get_volumes": 90 + }, + "mypy_relaxed": [], + "python_file_lines": {}, + "untyped_public": [] +} -- 2.54.0 From e8c09ac37cacf0471e204e35372dcb16275b2c98 Mon Sep 17 00:00:00 2001 From: Christian Manivong Date: Fri, 23 Oct 2026 16:01:56 +0200 Subject: [PATCH 4/4] chore(release): 0.3.0 --- CHANGELOG.md | 4 ++++ pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5912642..618443b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ All notable changes to this driver. The format follows ## [Unreleased] +## [0.3.0] - 2026-10-23 + +The first release on PyPI. + ### Changed - The driver follows the NAPALM driver standard (https://git.netork.io/NAPALM/driver-standard): CI on Gitea runs ruff, mypy, the diff --git a/pyproject.toml b/pyproject.toml index 02bb2ad..f485760 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "napalm-openmediavault" -version = "0.2.0" +version = "0.3.0" description = "NAPALM driver for OpenMediaVault NAS (SSH)" readme = "README.md" requires-python = ">=3.10" -- 2.54.0