Metadata-Version: 2.4
Name: napalm-qnap-qts
Version: 0.6.0
Summary: NAPALM driver for QNAP NAS systems running QTS via SSH
Author-email: Christian Manivong <christian@manivong.de>
License-Expression: Apache-2.0
Project-URL: Repository, https://git.netork.io/NAPALM/napalm-qnap-qts
Project-URL: Issues, https://git.netork.io/NAPALM/napalm-qnap-qts/issues
Project-URL: Changelog, https://git.netork.io/NAPALM/napalm-qnap-qts/src/branch/main/CHANGELOG.md
Keywords: napalm,network,automation,qnap,qts,nas,storage,ssh,driver
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: System :: Networking
Classifier: Topic :: System :: Systems Administration
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: napalm>=4.0
Requires-Dist: napalm-device-types>=4.22.0
Requires-Dist: napalm-linux>=0.15.0
Requires-Dist: netmiko>=4.0.0
Requires-Dist: paramiko>=5.0.0
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: pytest-cov>=5; extra == "dev"
Requires-Dist: mypy>=1.11; extra == "dev"
Requires-Dist: ruff>=0.6; extra == "dev"
Dynamic: license-file

# napalm-qnap-qts

NAPALM driver for QNAP NAS systems running QTS, over SSH.

QTS is a Linux distribution, so this driver inherits the whole OS surface from
[`napalm-linux`](https://git.netork.io/NAPALM/napalm-linux) —
packages, services, users, processes, Docker — and adds QNAP's storage, QPKG
and virtualisation layers on top.

Targets QTS 4.x and QTS 5.x.

## Status

The class scaffold, discovery fingerprints and version/tool detection are in
place. The storage, QPKG and VM parsers are **not written yet**: they are
blocked on capturing real command output from hardware (see
[Harvesting fixtures](#harvesting-fixtures)). Writing parsers against guessed
output is how a driver ends up passing its own tests and failing on a real NAS.

| Method | Source | Status |
|---|---|---|
| `get_facts` | `getcfg`, `getsysinfo`, `/proc/uptime` | pending harvest |
| `get_interfaces`, `get_interfaces_ip` | `ip` / `ifconfig` | pending harvest |
| `get_disks` | `qcli_storage -d`, `get_hd_smartinfo` | pending harvest |
| `get_disk_pools` | `qcli_storage -p`, `/proc/mdstat` | pending harvest |
| `get_volumes` | `qcli_storage -v`, `df` | pending harvest |
| `get_shares` | `/etc/config/smb.conf`, `/etc/exports` | pending harvest |
| `get_storage_services` | `getcfg`, `ss -lntup` | pending harvest |
| `get_disk_smart` | `get_hd_smartinfo` | pending harvest |
| `get_packages` | QPKG (`qpkg.conf` / `qpkg_cli`) | pending harvest |
| `get_vms` | `virsh` (Virtualization Station) | pending harvest |
| `start_vm`, `stop_vm`, `reboot_vm` | `virsh` | pending harvest |
| `set_service_enabled` | `setcfg`, `/etc/init.d` | pending harvest |
| `get_device_warnings` | derived from the above | pending harvest |
| `container_engines`, `open_container_engine` | Container Station's docker, `system dial-stdio` | ✅ |
| `get_services`, `get_users`, `get_processes` | inherited from `LinuxDriver` | ✅ |
| `get_health_metrics` | inherited (UCD-MIB over SNMP) | ✅ |
| `ping`, `ping_sweep` | inherited from `LinuxDriver` | ✅ |
| Snapshots, quotas, replication, QPKG install/remove | — | out of scope for v1 |

## Requirements

SSH must be enabled on the NAS: **Control Panel → Telnet/SSH → Allow SSH
connection**. The driver connects on port 22 by default; the QTS web UI on
443/8080 is not used.

## Install

```bash
pip install -e vendor/napalm-device-types/ -e vendor/napalm-linux/ -e vendor/napalm-qnap-qts/
```

## Usage

```python
from napalm_qnap_qts import QnapQtsDriver

driver = QnapQtsDriver("nas.example.lan", "admin", "secret")
driver.open()
print(driver.get_facts())
driver.close()
```

Recognised `optional_args`: everything `napalm-linux` accepts (`port`,
`sudo_password`, `secret`, …). Unknown keys are ignored.

## Design notes

### Inheritance order

```python
class QnapQtsDriver(StorageDriver, LinuxDriver):
```

`StorageDriver` precedes `LinuxDriver` in the MRO, so its
`NotImplementedError` stubs shadow LinuxDriver's working implementations
wherever the names collide — `get_services`, `get_packages`,
`install_package`. Each collision is resolved with an explicit forwarding
method; `TestMroForwarding` guards that they stay resolved.

NAS services are exposed as `get_storage_services()`, not `get_services()`:
netOrk's poller reads the former for the storage snapshot and the latter for
the OS service list. Same convention as `napalm-openmediavault`.

### Device class

The driver sets `DEVICE_CLASS = "storage"` explicitly. Without it netOrk's
`issubclass` chain reaches `OSDriver` before `StorageDriver` and would file a
QNAP under "linux", hiding its Storage tab. VMs and containers stay visible
through capability introspection (`supports_vms`), not through this key — a
QNAP running Virtualization Station is a NAS *and* a hypervisor, and
`device_class` only holds one of those.

### Docker

Container Station does not put `docker` on `PATH`; it lives under
`/share/<pool>/.qpkg/container-station/`. This driver only says where:
`_container_engine_binary("docker")` returns the path it found, and
`open_container_engine("docker")` from napalm-device-types reaches the Engine
API through it. What runs on the engine is netOrk's (NetOrk/netork#765).

## Harvesting fixtures

```bash
./tools/harvest.sh admin@nas4.example.lan qts4
./tools/harvest.sh admin@nas5.example.lan qts5
./tools/sanitize.py tools/harvest-out/qts5 --extra-host mynas
```

`harvest.sh` runs the command set this driver parses over a single SSH session
and writes one file per command. `sanitize.py` replaces serial numbers, MACs,
IP addresses and hostnames with stable placeholders — cross-references between
files survive, so the fixtures still describe one coherent device.

**Read the sanitised output before committing it.** The sanitiser catches
patterns, not judgement, and fixtures live in git forever. Raw harvest output
is gitignored and must never be committed.

Where QTS 4 and QTS 5 differ, keep both fixtures and parametrise the test over
the pair, so the version divergence is part of the test matrix rather than a
later surprise.

## Development

```bash
pip install -e ".[dev]"
python -m pytest -q
ruff check .
```

## License

Apache-2.0
