Declaring the mixin.OPNsenseDriver now declares napalm-device-types' DhcpLeasesMixin. It does so through OPNsenseDhcpLeasesMixin(DhcpLeasesMixin) in the new napalm_opnsense/dhcp_leases.py, the same pattern as OPNsenseTimeSyncMixin and OPNsenseScheduledJobsMixin. Contract tests and isinstance checks now find OPNsense.
get_dhcp_leases() moves there from opnsense.py and is typed -> list[DhcpLeaseDict]. The new module is under strict mypy, unlike opnsense.py, so mypy now checks the return shape against the declared contract.
It still reads the same sources in the same order: Kea, then ISC DHCP, then the ARP table fallback. The empty-answer and raise rules from #27 are unchanged. The method is split into small helpers, so opnsense.py shrinks from 3019 to 2914 lines and the baseline's get_dhcp_leases entries go away.
The floor is now napalm-device-types>=4.54.0.
Matching the declared shape.
A MAC is normalised to lower-case colon form with device-types' normalize_mac, so AA-BB-CC-DD-EE-01 reads as aa:bb:cc:dd:ee:01.
Kea's numeric state 0 is kept as "0". Before, it came out as "".
A Kea answer that is a plain list is read. Before, it raised AttributeError and counted as a failed source.
The ARP fallback rows stay as they are, with state: "arp". netOrk never stores them as leases.
Every row from Kea, from ISC and from the ARP fallback has exactly the declared keys, each of its declared type, with a colon-form MAC.
CHANGELOG under [Unreleased]. Following this repo's practice, the version is bumped in a separate chore(release) commit, so it stays at 0.6.0 here.
Tests, run against napalm-device-types main plus #149:
Full suite: 654 passed, 86.05% coverage (floor 79). It took 30 minutes locally only because DNS lookups are slow on the test machine.
Also green: ruff check, ruff format --check, mypy napalm_opnsense, napalm-standard ratchet and napalm-standard check.
Priority: P4. The gap is only the declaration; netOrk calls the method either way.
Closes #53
**Declaring the mixin.** `OPNsenseDriver` now declares napalm-device-types' `DhcpLeasesMixin`. It does so through `OPNsenseDhcpLeasesMixin(DhcpLeasesMixin)` in the new `napalm_opnsense/dhcp_leases.py`, the same pattern as `OPNsenseTimeSyncMixin` and `OPNsenseScheduledJobsMixin`. Contract tests and `isinstance` checks now find OPNsense.
- `get_dhcp_leases()` moves there from `opnsense.py` and is typed `-> list[DhcpLeaseDict]`. The new module is under strict mypy, unlike `opnsense.py`, so mypy now checks the return shape against the declared contract.
- It still reads the same sources in the same order: Kea, then ISC DHCP, then the ARP table fallback. The empty-answer and raise rules from #27 are unchanged. The method is split into small helpers, so `opnsense.py` shrinks from 3019 to 2914 lines and the baseline's `get_dhcp_leases` entries go away.
- The floor is now `napalm-device-types>=4.54.0`.
**Matching the declared shape.**
- A MAC is normalised to lower-case colon form with device-types' `normalize_mac`, so `AA-BB-CC-DD-EE-01` reads as `aa:bb:cc:dd:ee:01`.
- Kea's numeric state `0` is kept as `"0"`. Before, it came out as `""`.
- A Kea answer that is a plain list is read. Before, it raised `AttributeError` and counted as a failed source.
- The ARP fallback rows stay as they are, with `state: "arp"`. netOrk never stores them as leases.
**Contract test:** `tests/unit/test_dhcp_leases_contract.py`.
- `issubclass` and `isinstance` against the mixin.
- The method signature.
- Every row from Kea, from ISC and from the ARP fallback has exactly the declared keys, each of its declared type, with a colon-form MAC.
CHANGELOG under `[Unreleased]`. Following this repo's practice, the version is bumped in a separate `chore(release)` commit, so it stays at 0.6.0 here.
Tests, run against napalm-device-types `main` plus #149:
- Full suite: 654 passed, 86.05% coverage (floor 79). It took 30 minutes locally only because DNS lookups are slow on the test machine.
- Also green: `ruff check`, `ruff format --check`, `mypy napalm_opnsense`, `napalm-standard ratchet` and `napalm-standard check`.
Priority: P4. The gap is only the declaration; netOrk calls the method either way.
OPNsenseDriver implemented get_dhcp_leases without declaring
napalm-device-types' DhcpLeasesMixin, so contract tests and isinstance
checks missed it and nothing checked it against the declared signature.
It now lives in OPNsenseDhcpLeasesMixin(DhcpLeasesMixin), under strict
mypy and typed as DhcpLeaseDict; the floor is napalm-device-types
4.54.0.
Every row has the declared shape: the MAC normalised to lower-case
colon form, a numeric Kea state kept as its text, and a Kea answer that
is a plain list read instead of failing. The ARP fallback keeps its
state "arp" rows.
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.
Closes #53
Declaring the mixin.
OPNsenseDrivernow declares napalm-device-types'DhcpLeasesMixin. It does so throughOPNsenseDhcpLeasesMixin(DhcpLeasesMixin)in the newnapalm_opnsense/dhcp_leases.py, the same pattern asOPNsenseTimeSyncMixinandOPNsenseScheduledJobsMixin. Contract tests andisinstancechecks now find OPNsense.get_dhcp_leases()moves there fromopnsense.pyand is typed-> list[DhcpLeaseDict]. The new module is under strict mypy, unlikeopnsense.py, so mypy now checks the return shape against the declared contract.opnsense.pyshrinks from 3019 to 2914 lines and the baseline'sget_dhcp_leasesentries go away.napalm-device-types>=4.54.0.Matching the declared shape.
normalize_mac, soAA-BB-CC-DD-EE-01reads asaa:bb:cc:dd:ee:01.0is kept as"0". Before, it came out as"".AttributeErrorand counted as a failed source.state: "arp". netOrk never stores them as leases.Contract test:
tests/unit/test_dhcp_leases_contract.py.issubclassandisinstanceagainst the mixin.CHANGELOG under
[Unreleased]. Following this repo's practice, the version is bumped in a separatechore(release)commit, so it stays at 0.6.0 here.Tests, run against napalm-device-types
mainplus #149:ruff check,ruff format --check,mypy napalm_opnsense,napalm-standard ratchetandnapalm-standard check.Priority: P4. The gap is only the declaration; netOrk calls the method either way.