fix: IP-Bereiche mit korrekten Adresstypen erstellen

- Start- und Endadressen als netaddr-Objekte übergeben
- Fehler einzelner IP-Adressen beim Abgleich protokollieren
- IP-Netzübersicht direkt im IPAM-Menü registrieren
- Plugin-Version auf 1.2.1 erhöhen
This commit is contained in:
2026-07-23 12:17:14 +02:00
parent 8be6978d81
commit d904d335a9
7 changed files with 47 additions and 20 deletions
+5 -2
View File
@@ -1,6 +1,7 @@
import ipaddress
import logging
import netaddr
from django.db import transaction
from ipam.models import IPRange
from netbox.plugins import get_plugin_config
@@ -46,8 +47,10 @@ def ensure_range_for_ip(ip, *, config=None):
elif network.version == 6 and network.prefixlen < 127:
first += 1
start_address = f"{ipaddress.ip_address(first)}/{network.prefixlen}"
end_address = f"{ipaddress.ip_address(last)}/{network.prefixlen}"
# IPRange.save() performs arithmetic on the field values before Django's
# field conversion runs, so these must be netaddr objects rather than strings.
start_address = netaddr.IPNetwork(f"{ipaddress.ip_address(first)}/{network.prefixlen}")
end_address = netaddr.IPNetwork(f"{ipaddress.ip_address(last)}/{network.prefixlen}")
lookup = {
"start_address": start_address,
"end_address": end_address,