use napalm-device-types' normalize_mac and ConfigLifecycleMixin #13

Open
opened 2026-10-06 17:31:30 +00:00 by christianmanivong · 0 comments
Owner

Two things napalm-device-types already provides, which this driver re-implements.

utils.normalize_mac (napalm_proxmox/utils.py:28)

  • It parses with netaddr.EUI. napalm-device-types has normalize_mac (dhcp.py:59), and NetOrk matches MACs on that one.
  • Valid MACs come out the same. Invalid input does not: proxmox rewrites - to : and lowercases, while the base returns the input lowercased and stripped.
  • Callers: utils.py:166, :243 and interfaces_mixin.py:51, :149, :187, :227, :258.

ProxmoxConfigMixin (config_mixin.py:26) hand-rolls load_merge_candidate/load_replace_candidate, which are identical to each other (:71, :85).

  • They raise ValueError instead of MergeConfigException/ReplaceConfigException.
  • They never record the mode, so merge and replace both overwrite /etc/network/interfaces.
  • compare_config diffs against a cached _running_config instead of a _get_running_config() hook.

Proposal: import the base normalize_mac. Inherit ConfigLifecycleMixin, implement _get_running_config(), keep commit_config, and reject merge mode explicitly or document it.

Prio P4.

From the NetOrk function index (NetOrk/netork#670); every location was checked against the current code. Paths are relative to each driver repo.

Two things napalm-device-types already provides, which this driver re-implements. **`utils.normalize_mac`** (`napalm_proxmox/utils.py`:28) - It parses with `netaddr.EUI`. napalm-device-types has `normalize_mac` (`dhcp.py`:59), and NetOrk matches MACs on that one. - Valid MACs come out the same. Invalid input does not: proxmox rewrites `-` to `:` and lowercases, while the base returns the input lowercased and stripped. - Callers: `utils.py`:166, :243 and `interfaces_mixin.py`:51, :149, :187, :227, :258. **`ProxmoxConfigMixin`** (`config_mixin.py`:26) hand-rolls `load_merge_candidate`/`load_replace_candidate`, which are identical to each other (:71, :85). - They raise `ValueError` instead of `MergeConfigException`/`ReplaceConfigException`. - They never record the mode, so merge and replace both overwrite `/etc/network/interfaces`. - `compare_config` diffs against a cached `_running_config` instead of a `_get_running_config()` hook. **Proposal:** import the base `normalize_mac`. Inherit `ConfigLifecycleMixin`, implement `_get_running_config()`, keep `commit_config`, and reject merge mode explicitly or document it. Prio P4. From the NetOrk function index (NetOrk/netork#670); every location was checked against the current code. Paths are relative to each driver repo.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: NAPALM/napalm-proxmox#13