Switch and access point: each is a device of its own, read either through its controller or over SSH.
Through the controller:
UniFi OS console: API key, Network 9.0.108 and later, or a local admin login.
Standalone Network application: local admin login.
The controller's certificate is trusted on first use and pinned before any login. The device is found by its MAC or its address, in any site.
Over SSH:mca-dump and /tmp/running.cfg, with the host key checked by HostKeyCheck. Never an agent, never a key file of the host. Read only.
What they read: facts, ports as Port <n> plus Management, LLDP (both firmware shapes), the MAC table (SSH only), PoE, VLANs with their ports, SSIDs, radios, wireless clients.
VLANs through the controller follow the precedence documented in docs/PORT_VLANS.md (override, then profile, then default). Over SSH only the untagged VLAN is known, and tagged is left empty rather than guessed.
Controller:get_managed_devices() uses the Integration API and includes devices waiting for adoption on 10.x. Without the Integration API it falls back to the classic API.
Client:
One requests session; redirects are never followed.
CSRF is handled for both kinds of controller.
429 raises RateLimited with the wait, and no retry.
MFA (499) names the way in: a local admin or an API key.
A wrong site is an error, not an empty site.
UniFi OS and a standalone controller are told apart by GET / (200 vs. 302), as aiounifi does.
Simulator (sim/unifi_sim, not part of the package):
A controller on HTTPS: UniFi OS or standalone, the Integration API by version, the classic API, logins with CSRF, API keys, MFA, the rate limit, a wrong site, redirects, and port-override writes.
A switch on SSH.
tests/test_sim_e2e.py runs all three drivers against it over real TLS and SSH, certificate and host key refusals included.
A CLI and a Dockerfile run it by hand. The Dockerfile has not been built yet.
Fixtures: recorded answers from aiounifi (MIT, licence alongside) and abates/napalm-unifi (Apache-2.0), anonymised with tools/sanitize.py. The Integration fixtures are assembled from Ubiquiti's published 10.6.106 schemas. Sources are in tests/fixtures/README.md. Nothing is from our own devices yet.
250 tests, 99 % coverage, ruff and mypy --strict clean.
NAPALM drivers for Ubiquiti UniFi, read paths (NetOrk/netork#2787). Writes come in a later PR.
| Driver | Role |
|---|---|
| `unifi_switch` | `SwitchDriver` |
| `unifi_ap` | `AccessPointDriver` |
| `unifi_network` | `NetworkControllerDriver` (device-types 4.60.0, NAPALM/napalm-device-types#151) |
**Switch and access point:** each is a device of its own, read either through its controller or over SSH.
- **Through the controller:**
- UniFi OS console: API key, Network 9.0.108 and later, or a local admin login.
- Standalone Network application: local admin login.
- The controller's certificate is trusted on first use and pinned before any login. The device is found by its MAC or its address, in any site.
- **Over SSH:** `mca-dump` and `/tmp/running.cfg`, with the host key checked by `HostKeyCheck`. Never an agent, never a key file of the host. Read only.
- **What they read:** facts, ports as `Port <n>` plus `Management`, LLDP (both firmware shapes), the MAC table (SSH only), PoE, VLANs with their ports, SSIDs, radios, wireless clients.
- VLANs through the controller follow the precedence documented in `docs/PORT_VLANS.md` (override, then profile, then default). Over SSH only the untagged VLAN is known, and tagged is left empty rather than guessed.
**Controller:** `get_managed_devices()` uses the Integration API and includes devices waiting for adoption on 10.x. Without the Integration API it falls back to the classic API.
**Client:**
- One `requests` session; redirects are never followed.
- CSRF is handled for both kinds of controller.
- 429 raises `RateLimited` with the wait, and no retry.
- MFA (499) names the way in: a local admin or an API key.
- A wrong site is an error, not an empty site.
- UniFi OS and a standalone controller are told apart by `GET /` (200 vs. 302), as aiounifi does.
**Simulator** (`sim/unifi_sim`, not part of the package):
- A controller on HTTPS: UniFi OS or standalone, the Integration API by version, the classic API, logins with CSRF, API keys, MFA, the rate limit, a wrong site, redirects, and port-override writes.
- A switch on SSH.
- `tests/test_sim_e2e.py` runs all three drivers against it over real TLS and SSH, certificate and host key refusals included.
- A CLI and a Dockerfile run it by hand. The Dockerfile has not been built yet.
**Fixtures:** recorded answers from aiounifi (MIT, licence alongside) and abates/napalm-unifi (Apache-2.0), anonymised with `tools/sanitize.py`. The Integration fixtures are assembled from Ubiquiti's published 10.6.106 schemas. Sources are in `tests/fixtures/README.md`. Nothing is from our own devices yet.
250 tests, 99 % coverage, ruff and mypy --strict clean.
Needs napalm-device-types 4.60.0 on PyPI (NAPALM/napalm-device-types#151) before CI can install it.
Facts, ports, management address, LLDP (per-port and top-level shapes),
MAC table and PoE from a UniFi device record, which a controller's
stat/device and the device's own mca-dump share. Fixtures from aiounifi
(MIT) and abates/napalm-unifi (Apache-2.0), anonymised with
tools/sanitize.py.
Refs NetOrk/netork#2787
Integration fixtures are assembled from the shapes of Ubiquiti's published
OpenAPI spec (10.6.106), which carries no whole-response examples.
Refs NetOrk/netork#2787
API key or local login, CSRF token, no redirects followed, a login rate
limit that backs off, MFA accounts refused with the way in, a wrong site
told apart from an empty one, paged Integration lists.
Refs NetOrk/netork#2787
ControllerSource reads a device's stat/device entry, its networks and port
profiles, the stations and the WLANs from its controller; SshSource reads the
device's own mca-dump and running.cfg. Both hand the drivers the same record,
read once per connection.
paramiko through HostKeyCheck: trust on first use, a changed key refused
before any login. Only the password or key given is offered, never an agent
or a key file; Ed25519, ECDSA and RSA keys are read.
The controller's certificate is trusted on first use and pinned for the
session before any login. An api_token profile's secret is the API key;
otherwise a local admin's login, separate or the driver's own.
UnifiDevice reads a device through its controller (found by MAC or by its
address, in any site) or over SSH (a separate SSH profile, or the driver's own
login with a key file): facts, ports, management address, LLDP and MAC table.
UnifiSwitchDriver adds PoE and VLANs (with their ports, and NAPALM's
get_vlans from them); UnifiAccessPointDriver adds SSIDs, radios and wireless
clients. Discovery knows Ubiquiti's OUIs from the IEEE registry.
UnifiNetworkDriver names the devices a controller manages: through the
Integration API, with the devices still waiting for adoption on Network 10,
and through the classic API on controllers without it. Its own ports are
none of its devices'. Every entry point is checked against its driver.
The fixtures' sources and licences: aiounifi (MIT, its licence alongside),
abates/napalm-unifi (Apache-2.0) and the Integration API's published schemas.
With an API key and a known MAC, opening sent no request at all: a refused
key, a redirect or a device the controller does not know showed only at the
first getter. Open now reads the device and closes again when that fails.
The client took a 404 on /api/auth/login for a standalone controller, but a
standalone controller may well answer an unknown API path with 401 and the
login was then refused. Like aiounifi, it now asks / first: UniFi OS serves
its page, the standalone application redirects to /manage. A login that
redirects is refused instead of taken for a success.
sim/unifi_sim plays a UniFi Network controller on HTTPS (UniFi OS or
standalone, Integration API by version, classic API, logins with CSRF, API
keys, MFA, rate limit, wrong site, redirects, port override writes) and a
switch on SSH, from the fixtures. The end-to-end tests run all three drivers
against it over real TLS and SSH, certificate and host key checks included.
A command line and a Dockerfile run it by hand or on a test server.
An adopted switch or access point carries driver (unifi_switch, unifi_ap)
and driver_args (controller transport, URL, site, MAC; no secret), so netOrk
can add it with the controller's credential. A device waiting for adoption
and a gateway get none. The end-to-end test opens an access point with
exactly what the controller reported.
The standard's ratchet counted 12 for parse_vlans_detail_classic and 11 for
_encryption. Placing one port in its VLANs and naming a PSK's encryption are
functions of their own now; nothing changes in what they return.
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.
NAPALM drivers for Ubiquiti UniFi, read paths (NetOrk/netork#2787). Writes come in a later PR.
unifi_switchSwitchDriverunifi_apAccessPointDriverunifi_networkNetworkControllerDriver(device-types 4.60.0, NAPALM/napalm-device-types#151)Switch and access point: each is a device of its own, read either through its controller or over SSH.
mca-dumpand/tmp/running.cfg, with the host key checked byHostKeyCheck. Never an agent, never a key file of the host. Read only.Port <n>plusManagement, LLDP (both firmware shapes), the MAC table (SSH only), PoE, VLANs with their ports, SSIDs, radios, wireless clients.docs/PORT_VLANS.md(override, then profile, then default). Over SSH only the untagged VLAN is known, and tagged is left empty rather than guessed.Controller:
get_managed_devices()uses the Integration API and includes devices waiting for adoption on 10.x. Without the Integration API it falls back to the classic API.Client:
requestssession; redirects are never followed.RateLimitedwith the wait, and no retry.GET /(200 vs. 302), as aiounifi does.Simulator (
sim/unifi_sim, not part of the package):tests/test_sim_e2e.pyruns all three drivers against it over real TLS and SSH, certificate and host key refusals included.Fixtures: recorded answers from aiounifi (MIT, licence alongside) and abates/napalm-unifi (Apache-2.0), anonymised with
tools/sanitize.py. The Integration fixtures are assembled from Ubiquiti's published 10.6.106 schemas. Sources are intests/fixtures/README.md. Nothing is from our own devices yet.250 tests, 99 % coverage, ruff and mypy --strict clean.
Needs napalm-device-types 4.60.0 on PyPI (NAPALM/napalm-device-types#151) before CI can install it.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.