feat: automatische Prefix-Zuordnung und IP-Netzübersicht hinzufügen
- fehlende Prefixe beim Speichern von IP-Adressen automatisch erstellen - VRF, Mandant, Standort und Lokation übernehmen - bestehende IP-Adressen per Management-Command abgleichen - filterbare IP-Netzübersicht für Regionen, Standorte und Mandanten ergänzen - NetBox 4.6.5 unterstützen
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import logging
|
||||
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
from ipam.models import IPAddress
|
||||
from netbox.plugins import get_plugin_config
|
||||
|
||||
from .services import ensure_prefix_for_ip
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@receiver(post_save, sender=IPAddress, dispatch_uid="netbox_better_ips.ensure_prefix")
|
||||
def ensure_ip_prefix(sender, instance, raw=False, **kwargs):
|
||||
if raw or not get_plugin_config("netbox_better_ips", "auto_create_prefix"):
|
||||
return
|
||||
try:
|
||||
ensure_prefix_for_ip(instance)
|
||||
except Exception:
|
||||
# The IP save must not be rolled back by an optional convenience feature.
|
||||
logger.exception("Could not ensure a prefix for IP address %s", instance)
|
||||
|
||||
Reference in New Issue
Block a user