From aec3a25b834a2e950566965ec65ed844fed09b09 Mon Sep 17 00:00:00 2001 From: Matej Hyks Date: Fri, 31 Oct 2025 09:36:16 +0100 Subject: [PATCH 1/3] clone static fields --- netbox_routing/models/static.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox_routing/models/static.py b/netbox_routing/models/static.py index 5312812..af9aaff 100644 --- a/netbox_routing/models/static.py +++ b/netbox_routing/models/static.py @@ -52,7 +52,7 @@ class StaticRoute(PrimaryModel): null=True, ) - clone_fields = ('vrf', 'metric', 'permanent') + clone_fields = ('devices', 'prefix', 'next_hop', 'vrf', 'metric', 'permanent') prerequisite_models = ('dcim.Device',) class Meta: From d33afc5c17ee916b1938ddc74b3568792d0795b2 Mon Sep 17 00:00:00 2001 From: Matej Hyks Date: Fri, 31 Oct 2025 11:23:53 +0100 Subject: [PATCH 2/3] clone field and prerequisites --- netbox_routing/models/eigrp.py | 14 ++++++++++++++ netbox_routing/models/ospf.py | 7 +++++-- netbox_routing/models/static.py | 2 +- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/netbox_routing/models/eigrp.py b/netbox_routing/models/eigrp.py index dd199ab..ab01262 100644 --- a/netbox_routing/models/eigrp.py +++ b/netbox_routing/models/eigrp.py @@ -36,6 +36,10 @@ class EIGRPRouter(PrimaryModel): ) rid = IPAddressField(verbose_name=_('Router ID'), blank=True, null=True) + clone_fields = ('device', 'mode', 'name', 'pid', 'rid') + + prerequisite_models = ('dcim.Device',) + class Meta: verbose_name = 'EIGRP Router' @@ -80,6 +84,10 @@ class EIGRPAddressFamily(PrimaryModel): ) rid = IPAddressField(verbose_name=_('Router ID'), blank=True, null=True) + clone_fields = ('router', 'vrf', 'family') + + prerequisite_models = ('netbox_routing.EIGRPRouter',) + class Meta: verbose_name = 'EIGRP Address Family' constraints = ( @@ -121,6 +129,9 @@ class EIGRPNetwork(PrimaryModel): blank=False, null=False, ) + + clone_fields = ('router', 'address_family', 'network') + prerequisite_models = ('netbox_routing.EIGRPRouter', 'ipam.Prefix',) class Meta: verbose_name = 'EIGRP Network' @@ -183,6 +194,9 @@ class EIGRPInterface(PrimaryModel): passphrase = models.CharField( verbose_name=_('Passphrase'), max_length=200, blank=True, null=True ) + + clone_fields = ('router', 'address_family', 'interface', 'passive', 'bfd', 'authentication', 'passphrase') + prerequisite_models = ('netbox_routing.EIGRPRouter', 'dcim.Interface',) class Meta: verbose_name = 'EIGRP Interface' diff --git a/netbox_routing/models/ospf.py b/netbox_routing/models/ospf.py index aa13587..6eead0f 100644 --- a/netbox_routing/models/ospf.py +++ b/netbox_routing/models/ospf.py @@ -38,7 +38,7 @@ class OSPFInstance(PrimaryModel): null=True, ) - clone_fields = ('device',) + clone_fields = ('name', 'router_id', 'process_id', 'device', 'vrf') prerequisite_models = ('dcim.Device',) class Meta: @@ -62,7 +62,7 @@ class OSPFArea(PrimaryModel): default='standard', ) prerequisite_models = () - clone_fields = () + clone_fields = ('area_id', 'area_type') class Meta: ordering = ['area_id'] @@ -123,8 +123,11 @@ class OSPFInterface(PrimaryModel): passphrase = models.CharField(max_length=200, blank=True, null=True) clone_fields = ( + 'device', 'instance', 'area', + 'interface', + 'passive', 'priority', 'bfd', 'authentication', diff --git a/netbox_routing/models/static.py b/netbox_routing/models/static.py index af9aaff..ad53ce9 100644 --- a/netbox_routing/models/static.py +++ b/netbox_routing/models/static.py @@ -52,7 +52,7 @@ class StaticRoute(PrimaryModel): null=True, ) - clone_fields = ('devices', 'prefix', 'next_hop', 'vrf', 'metric', 'permanent') + clone_fields = ('name', 'devices', 'prefix', 'next_hop', 'vrf', 'metric', 'permanent') prerequisite_models = ('dcim.Device',) class Meta: From 5f0fe831cd34e350e9b948f1c80f34b2b502005b Mon Sep 17 00:00:00 2001 From: Matej Hyks Date: Fri, 31 Oct 2025 11:29:59 +0100 Subject: [PATCH 3/3] formatting --- netbox_routing/models/eigrp.py | 34 ++++++++++++++++++++++++--------- netbox_routing/models/static.py | 11 ++++++++++- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/netbox_routing/models/eigrp.py b/netbox_routing/models/eigrp.py index ab01262..5799633 100644 --- a/netbox_routing/models/eigrp.py +++ b/netbox_routing/models/eigrp.py @@ -37,9 +37,9 @@ class EIGRPRouter(PrimaryModel): rid = IPAddressField(verbose_name=_('Router ID'), blank=True, null=True) clone_fields = ('device', 'mode', 'name', 'pid', 'rid') - + prerequisite_models = ('dcim.Device',) - + class Meta: verbose_name = 'EIGRP Router' @@ -85,9 +85,9 @@ class EIGRPAddressFamily(PrimaryModel): rid = IPAddressField(verbose_name=_('Router ID'), blank=True, null=True) clone_fields = ('router', 'vrf', 'family') - + prerequisite_models = ('netbox_routing.EIGRPRouter',) - + class Meta: verbose_name = 'EIGRP Address Family' constraints = ( @@ -129,9 +129,13 @@ class EIGRPNetwork(PrimaryModel): blank=False, null=False, ) - + clone_fields = ('router', 'address_family', 'network') - prerequisite_models = ('netbox_routing.EIGRPRouter', 'ipam.Prefix',) + + prerequisite_models = ( + 'netbox_routing.EIGRPRouter', + 'ipam.Prefix', + ) class Meta: verbose_name = 'EIGRP Network' @@ -194,9 +198,21 @@ class EIGRPInterface(PrimaryModel): passphrase = models.CharField( verbose_name=_('Passphrase'), max_length=200, blank=True, null=True ) - - clone_fields = ('router', 'address_family', 'interface', 'passive', 'bfd', 'authentication', 'passphrase') - prerequisite_models = ('netbox_routing.EIGRPRouter', 'dcim.Interface',) + + clone_fields = ( + 'router', + 'address_family', + 'interface', + 'passive', + 'bfd', + 'authentication', + 'passphrase', + ) + + prerequisite_models = ( + 'netbox_routing.EIGRPRouter', + 'dcim.Interface', + ) class Meta: verbose_name = 'EIGRP Interface' diff --git a/netbox_routing/models/static.py b/netbox_routing/models/static.py index ad53ce9..57331c8 100644 --- a/netbox_routing/models/static.py +++ b/netbox_routing/models/static.py @@ -52,7 +52,16 @@ class StaticRoute(PrimaryModel): null=True, ) - clone_fields = ('name', 'devices', 'prefix', 'next_hop', 'vrf', 'metric', 'permanent') + clone_fields = ( + 'name', + 'devices', + 'prefix', + 'next_hop', + 'vrf', + 'metric', + 'permanent', + ) + prerequisite_models = ('dcim.Device',) class Meta: