From e30fa775fde4c1683479091554dc3c990fd35c0a Mon Sep 17 00:00:00 2001 From: Matej Hyks Date: Mon, 18 Aug 2025 11:24:48 +0200 Subject: [PATCH 01/11] unique device name and routing instace combination --- netbox_routing/models/eigrp.py | 1 + netbox_routing/models/ospf.py | 1 + 2 files changed, 2 insertions(+) diff --git a/netbox_routing/models/eigrp.py b/netbox_routing/models/eigrp.py index dd199ab..55b5c96 100644 --- a/netbox_routing/models/eigrp.py +++ b/netbox_routing/models/eigrp.py @@ -38,6 +38,7 @@ class EIGRPRouter(PrimaryModel): class Meta: verbose_name = 'EIGRP Router' + unique_together=[["device","name"]] def __str__(self): if self.pid: diff --git a/netbox_routing/models/ospf.py b/netbox_routing/models/ospf.py index 5b5681a..802c3b2 100644 --- a/netbox_routing/models/ospf.py +++ b/netbox_routing/models/ospf.py @@ -44,6 +44,7 @@ class OSPFInstance(PrimaryModel): class Meta: ordering = ['vrf', 'router_id', 'process_id'] verbose_name = 'OSPF Instance' + unique_together = [['device', 'name']] def __str__(self): return f'{self.name} ({self.router_id})' From 42339f3255e6335ccef4247df09d0b0de2c6a5ad Mon Sep 17 00:00:00 2001 From: Matej Hyks Date: Mon, 18 Aug 2025 11:33:06 +0200 Subject: [PATCH 02/11] formating --- netbox_routing/models/eigrp.py | 2 +- netbox_routing/models/ospf.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/netbox_routing/models/eigrp.py b/netbox_routing/models/eigrp.py index 55b5c96..e9d5114 100644 --- a/netbox_routing/models/eigrp.py +++ b/netbox_routing/models/eigrp.py @@ -38,7 +38,7 @@ class EIGRPRouter(PrimaryModel): class Meta: verbose_name = 'EIGRP Router' - unique_together=[["device","name"]] + unique_together=[['device', 'name']] def __str__(self): if self.pid: diff --git a/netbox_routing/models/ospf.py b/netbox_routing/models/ospf.py index 802c3b2..d2ae721 100644 --- a/netbox_routing/models/ospf.py +++ b/netbox_routing/models/ospf.py @@ -44,7 +44,7 @@ class OSPFInstance(PrimaryModel): class Meta: ordering = ['vrf', 'router_id', 'process_id'] verbose_name = 'OSPF Instance' - unique_together = [['device', 'name']] + unique_together = [['device', 'name']] def __str__(self): return f'{self.name} ({self.router_id})' From 338f94685ee0c86281bca277f972a0be1507bdc9 Mon Sep 17 00:00:00 2001 From: Matej Hyks Date: Mon, 18 Aug 2025 11:36:56 +0200 Subject: [PATCH 03/11] formating --- netbox_routing/models/eigrp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netbox_routing/models/eigrp.py b/netbox_routing/models/eigrp.py index e9d5114..5d05fd7 100644 --- a/netbox_routing/models/eigrp.py +++ b/netbox_routing/models/eigrp.py @@ -38,7 +38,7 @@ class EIGRPRouter(PrimaryModel): class Meta: verbose_name = 'EIGRP Router' - unique_together=[['device', 'name']] + unique_together = [['device', 'name']] def __str__(self): if self.pid: From 146dd6e9429445e5714c0b595907ee84abb404a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Hyk=C5=A1?= <78847703+mrhyks@users.noreply.github.com> Date: Wed, 29 Oct 2025 13:57:36 +0100 Subject: [PATCH 04/11] Update netbox_routing/models/eigrp.py Co-authored-by: Daniel Sheppard --- netbox_routing/models/eigrp.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/netbox_routing/models/eigrp.py b/netbox_routing/models/eigrp.py index 5d05fd7..34b2cda 100644 --- a/netbox_routing/models/eigrp.py +++ b/netbox_routing/models/eigrp.py @@ -38,7 +38,14 @@ class EIGRPRouter(PrimaryModel): class Meta: verbose_name = 'EIGRP Router' - unique_together = [['device', 'name']] + constraints = ( + models.UniqueConstraint( + fields=('device', 'name'), + name='%(app_label)s_%(class)s_unique_device_name', + violation_error_message="Name must be unique per device. Only a single empty name is permitted per device", + nulls_distinct=False + ), + ) def __str__(self): if self.pid: From d8eb1cce5e932aa0e3047f8ce40469ed746af701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Hyk=C5=A1?= <78847703+mrhyks@users.noreply.github.com> Date: Wed, 29 Oct 2025 13:57:55 +0100 Subject: [PATCH 05/11] Update netbox_routing/models/ospf.py Co-authored-by: Daniel Sheppard --- netbox_routing/models/ospf.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/netbox_routing/models/ospf.py b/netbox_routing/models/ospf.py index d2ae721..084b8fb 100644 --- a/netbox_routing/models/ospf.py +++ b/netbox_routing/models/ospf.py @@ -44,7 +44,14 @@ class OSPFInstance(PrimaryModel): class Meta: ordering = ['vrf', 'router_id', 'process_id'] verbose_name = 'OSPF Instance' - unique_together = [['device', 'name']] + constraints = ( + models.UniqueConstraint( + fields=('device', 'name'), + name='%(app_label)s_%(class)s_unique_device_name', + violation_error_message="Name must be unique per device. Only a single empty name is permitted per device", + nulls_distinct=False + ), + ) def __str__(self): return f'{self.name} ({self.router_id})' From 431c9f4c888546e46cd6099f20a99478b75306b1 Mon Sep 17 00:00:00 2001 From: Matej Hyks Date: Wed, 29 Oct 2025 13:59:30 +0100 Subject: [PATCH 06/11] migrations --- .../migrations/0016_unique_together.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 netbox_routing/migrations/0016_unique_together.py diff --git a/netbox_routing/migrations/0016_unique_together.py b/netbox_routing/migrations/0016_unique_together.py new file mode 100644 index 0000000..8bfb28e --- /dev/null +++ b/netbox_routing/migrations/0016_unique_together.py @@ -0,0 +1,24 @@ +# Generated by Django 5.2.2 on 2025-10-29 12:58 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dcim', '0207_remove_redundant_indexes'), + ('extras', '0128_tableconfig'), + ('ipam', '0081_remove_service_device_virtual_machine_add_parent_gfk_index'), + ('netbox_routing', '0015_alter_ospfarea_options_alter_ospfinstance_options'), + ] + + operations = [ + migrations.AddConstraint( + model_name='eigrprouter', + constraint=models.UniqueConstraint(fields=('device', 'name'), name='netbox_routing_eigrprouter_unique_device_name', nulls_distinct=False, violation_error_message='Name must be unique per device. Only a single empty name is permitted per device'), + ), + migrations.AddConstraint( + model_name='ospfinstance', + constraint=models.UniqueConstraint(fields=('device', 'name'), name='netbox_routing_ospfinstance_unique_device_name', nulls_distinct=False, violation_error_message='Name must be unique per device. Only a single empty name is permitted per device'), + ), + ] From f318947d83877a8f8d2beed91ec6eec3977266b8 Mon Sep 17 00:00:00 2001 From: Matej Hyks Date: Wed, 29 Oct 2025 14:32:53 +0100 Subject: [PATCH 07/11] formatting --- netbox_routing/models/ospf.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/netbox_routing/models/ospf.py b/netbox_routing/models/ospf.py index 084b8fb..3b6d06e 100644 --- a/netbox_routing/models/ospf.py +++ b/netbox_routing/models/ospf.py @@ -49,7 +49,7 @@ class Meta: fields=('device', 'name'), name='%(app_label)s_%(class)s_unique_device_name', violation_error_message="Name must be unique per device. Only a single empty name is permitted per device", - nulls_distinct=False + nulls_distinct=False, ), ) diff --git a/pyproject.toml b/pyproject.toml index e2a54c4..02a7ad4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,5 +36,5 @@ exclude=["netbox_routing.tests"] [tool.black] skip-string-normalization = 1 -check = 1 +check = 0 diff = 0 \ No newline at end of file From 5d0585e86cad57230389968c6a3e06c7e469ff56 Mon Sep 17 00:00:00 2001 From: Matej Hyks Date: Thu, 30 Oct 2025 09:38:42 +0100 Subject: [PATCH 08/11] formatting --- .../migrations/0016_unique_together.py | 16 ++++++++++++++-- netbox_routing/models/eigrp.py | 5 +++-- netbox_routing/models/ospf.py | 3 ++- pyproject.toml | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/netbox_routing/migrations/0016_unique_together.py b/netbox_routing/migrations/0016_unique_together.py index 8bfb28e..73d5384 100644 --- a/netbox_routing/migrations/0016_unique_together.py +++ b/netbox_routing/migrations/0016_unique_together.py @@ -15,10 +15,22 @@ class Migration(migrations.Migration): operations = [ migrations.AddConstraint( model_name='eigrprouter', - constraint=models.UniqueConstraint(fields=('device', 'name'), name='netbox_routing_eigrprouter_unique_device_name', nulls_distinct=False, violation_error_message='Name must be unique per device. Only a single empty name is permitted per device'), + constraint=models.UniqueConstraint( + fields=('device', 'name'), + name='netbox_routing_eigrprouter_unique_device_name', + nulls_distinct=False, + violation_error_message="""Name must be unique per device. + Only a single empty name is permitted per device""", + ), ), migrations.AddConstraint( model_name='ospfinstance', - constraint=models.UniqueConstraint(fields=('device', 'name'), name='netbox_routing_ospfinstance_unique_device_name', nulls_distinct=False, violation_error_message='Name must be unique per device. Only a single empty name is permitted per device'), + constraint=models.UniqueConstraint( + fields=('device', 'name'), + name='netbox_routing_ospfinstance_unique_device_name', + nulls_distinct=False, + violation_error_message="""Name must be unique per device. + Only a single empty name is permitted per device""", + ), ), ] diff --git a/netbox_routing/models/eigrp.py b/netbox_routing/models/eigrp.py index 34b2cda..8fd66eb 100644 --- a/netbox_routing/models/eigrp.py +++ b/netbox_routing/models/eigrp.py @@ -42,8 +42,9 @@ class Meta: models.UniqueConstraint( fields=('device', 'name'), name='%(app_label)s_%(class)s_unique_device_name', - violation_error_message="Name must be unique per device. Only a single empty name is permitted per device", - nulls_distinct=False + violation_error_message="""Name must be unique per device. + Only a single empty name is permitted per device""", + nulls_distinct=False, ), ) diff --git a/netbox_routing/models/ospf.py b/netbox_routing/models/ospf.py index 3b6d06e..adb1b7b 100644 --- a/netbox_routing/models/ospf.py +++ b/netbox_routing/models/ospf.py @@ -48,7 +48,8 @@ class Meta: models.UniqueConstraint( fields=('device', 'name'), name='%(app_label)s_%(class)s_unique_device_name', - violation_error_message="Name must be unique per device. Only a single empty name is permitted per device", + violation_error_message="""Name must be unique per device. + Only a single empty name is permitted per device""", nulls_distinct=False, ), ) diff --git a/pyproject.toml b/pyproject.toml index 02a7ad4..e2a54c4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,5 +36,5 @@ exclude=["netbox_routing.tests"] [tool.black] skip-string-normalization = 1 -check = 0 +check = 1 diff = 0 \ No newline at end of file From 865d81eb6f2d34b397d0a03ebc99dba23ec3f409 Mon Sep 17 00:00:00 2001 From: Matej Hyks Date: Thu, 30 Oct 2025 09:49:10 +0100 Subject: [PATCH 09/11] conflicting migrations --- ...tbox_routing_eigrprouter_unique_device_name_and_more.py} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename netbox_routing/migrations/{0016_unique_together.py => 0016_eigrprouter_netbox_routing_eigrprouter_unique_device_name_and_more.py} (94%) diff --git a/netbox_routing/migrations/0016_unique_together.py b/netbox_routing/migrations/0016_eigrprouter_netbox_routing_eigrprouter_unique_device_name_and_more.py similarity index 94% rename from netbox_routing/migrations/0016_unique_together.py rename to netbox_routing/migrations/0016_eigrprouter_netbox_routing_eigrprouter_unique_device_name_and_more.py index 73d5384..6e08d53 100644 --- a/netbox_routing/migrations/0016_unique_together.py +++ b/netbox_routing/migrations/0016_eigrprouter_netbox_routing_eigrprouter_unique_device_name_and_more.py @@ -1,4 +1,4 @@ -# Generated by Django 5.2.2 on 2025-10-29 12:58 +# Generated by Django 5.2.2 on 2025-10-30 08:45 from django.db import migrations, models @@ -19,7 +19,7 @@ class Migration(migrations.Migration): fields=('device', 'name'), name='netbox_routing_eigrprouter_unique_device_name', nulls_distinct=False, - violation_error_message="""Name must be unique per device. + violation_error_message="""Name must be unique per device.\n Only a single empty name is permitted per device""", ), ), @@ -29,7 +29,7 @@ class Migration(migrations.Migration): fields=('device', 'name'), name='netbox_routing_ospfinstance_unique_device_name', nulls_distinct=False, - violation_error_message="""Name must be unique per device. + violation_error_message="""Name must be unique per device.\n Only a single empty name is permitted per device""", ), ), From 522dc9b9e6cdf58a3f12834878807a75eadc5443 Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Thu, 30 Oct 2025 08:26:38 -0500 Subject: [PATCH 10/11] Rename 0016_eigrprouter_netbox_routing_eigrprouter_unique_device_name_and_more.py to 0017_eigrprouter_netbox_routing_eigrprouter_unique_device_name_and_more.py --- ...ter_netbox_routing_eigrprouter_unique_device_name_and_more.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename netbox_routing/migrations/{0016_eigrprouter_netbox_routing_eigrprouter_unique_device_name_and_more.py => 0017_eigrprouter_netbox_routing_eigrprouter_unique_device_name_and_more.py} (100%) diff --git a/netbox_routing/migrations/0016_eigrprouter_netbox_routing_eigrprouter_unique_device_name_and_more.py b/netbox_routing/migrations/0017_eigrprouter_netbox_routing_eigrprouter_unique_device_name_and_more.py similarity index 100% rename from netbox_routing/migrations/0016_eigrprouter_netbox_routing_eigrprouter_unique_device_name_and_more.py rename to netbox_routing/migrations/0017_eigrprouter_netbox_routing_eigrprouter_unique_device_name_and_more.py From 57002a8ed5a3eb4ad318edaaa4e9e641829661b5 Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Thu, 30 Oct 2025 08:27:03 -0500 Subject: [PATCH 11/11] Update netbox_routing/migrations/0017_eigrprouter_netbox_routing_eigrprouter_unique_device_name_and_more.py --- ...netbox_routing_eigrprouter_unique_device_name_and_more.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/netbox_routing/migrations/0017_eigrprouter_netbox_routing_eigrprouter_unique_device_name_and_more.py b/netbox_routing/migrations/0017_eigrprouter_netbox_routing_eigrprouter_unique_device_name_and_more.py index 6e08d53..6ddbc2c 100644 --- a/netbox_routing/migrations/0017_eigrprouter_netbox_routing_eigrprouter_unique_device_name_and_more.py +++ b/netbox_routing/migrations/0017_eigrprouter_netbox_routing_eigrprouter_unique_device_name_and_more.py @@ -6,10 +6,7 @@ class Migration(migrations.Migration): dependencies = [ - ('dcim', '0207_remove_redundant_indexes'), - ('extras', '0128_tableconfig'), - ('ipam', '0081_remove_service_device_virtual_machine_add_parent_gfk_index'), - ('netbox_routing', '0015_alter_ospfarea_options_alter_ospfinstance_options'), + ('netbox_routing', '0016_ospfinterface_interface_onetoonefield'), ] operations = [