mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Closes #14536: Enable ENFORCE_GLOBAL_UNIQUE by default
This commit is contained in:
@ -103,9 +103,12 @@ The maximum size (in bytes) of an incoming HTTP request (i.e. `GET` or `POST` da
|
|||||||
|
|
||||||
!!! tip "Dynamic Configuration Parameter"
|
!!! tip "Dynamic Configuration Parameter"
|
||||||
|
|
||||||
Default: False
|
Default: True
|
||||||
|
|
||||||
By default, NetBox will permit users to create duplicate prefixes and IP addresses in the global table (that is, those which are not assigned to any VRF). This behavior can be disabled by setting `ENFORCE_GLOBAL_UNIQUE` to True.
|
By default, NetBox will prevent the creation of duplicate prefixes and IP addresses in the global table (that is, those which are not assigned to any VRF). This validation can be disabled by setting `ENFORCE_GLOBAL_UNIQUE` to False.
|
||||||
|
|
||||||
|
!!! info "Changed in v3.7"
|
||||||
|
The default value for this parameter was changed from False to True in NetBox v3.7.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -232,7 +232,6 @@ class TestPrefix(TestCase):
|
|||||||
duplicate_prefix = Prefix(prefix=IPNetwork('192.0.2.0/24'))
|
duplicate_prefix = Prefix(prefix=IPNetwork('192.0.2.0/24'))
|
||||||
self.assertIsNone(duplicate_prefix.clean())
|
self.assertIsNone(duplicate_prefix.clean())
|
||||||
|
|
||||||
@override_settings(ENFORCE_GLOBAL_UNIQUE=True)
|
|
||||||
def test_duplicate_global_unique(self):
|
def test_duplicate_global_unique(self):
|
||||||
Prefix.objects.create(prefix=IPNetwork('192.0.2.0/24'))
|
Prefix.objects.create(prefix=IPNetwork('192.0.2.0/24'))
|
||||||
duplicate_prefix = Prefix(prefix=IPNetwork('192.0.2.0/24'))
|
duplicate_prefix = Prefix(prefix=IPNetwork('192.0.2.0/24'))
|
||||||
@ -471,7 +470,6 @@ class TestIPAddress(TestCase):
|
|||||||
duplicate_ip = IPAddress(address=IPNetwork('192.0.2.1/24'))
|
duplicate_ip = IPAddress(address=IPNetwork('192.0.2.1/24'))
|
||||||
self.assertIsNone(duplicate_ip.clean())
|
self.assertIsNone(duplicate_ip.clean())
|
||||||
|
|
||||||
@override_settings(ENFORCE_GLOBAL_UNIQUE=True)
|
|
||||||
def test_duplicate_global_unique(self):
|
def test_duplicate_global_unique(self):
|
||||||
IPAddress.objects.create(address=IPNetwork('192.0.2.1/24'))
|
IPAddress.objects.create(address=IPNetwork('192.0.2.1/24'))
|
||||||
duplicate_ip = IPAddress(address=IPNetwork('192.0.2.1/24'))
|
duplicate_ip = IPAddress(address=IPNetwork('192.0.2.1/24'))
|
||||||
@ -489,19 +487,16 @@ class TestIPAddress(TestCase):
|
|||||||
duplicate_ip = IPAddress(vrf=vrf, address=IPNetwork('192.0.2.1/24'))
|
duplicate_ip = IPAddress(vrf=vrf, address=IPNetwork('192.0.2.1/24'))
|
||||||
self.assertRaises(ValidationError, duplicate_ip.clean)
|
self.assertRaises(ValidationError, duplicate_ip.clean)
|
||||||
|
|
||||||
@override_settings(ENFORCE_GLOBAL_UNIQUE=True)
|
|
||||||
def test_duplicate_nonunique_nonrole_role(self):
|
def test_duplicate_nonunique_nonrole_role(self):
|
||||||
IPAddress.objects.create(address=IPNetwork('192.0.2.1/24'))
|
IPAddress.objects.create(address=IPNetwork('192.0.2.1/24'))
|
||||||
duplicate_ip = IPAddress(address=IPNetwork('192.0.2.1/24'), role=IPAddressRoleChoices.ROLE_VIP)
|
duplicate_ip = IPAddress(address=IPNetwork('192.0.2.1/24'), role=IPAddressRoleChoices.ROLE_VIP)
|
||||||
self.assertRaises(ValidationError, duplicate_ip.clean)
|
self.assertRaises(ValidationError, duplicate_ip.clean)
|
||||||
|
|
||||||
@override_settings(ENFORCE_GLOBAL_UNIQUE=True)
|
|
||||||
def test_duplicate_nonunique_role_nonrole(self):
|
def test_duplicate_nonunique_role_nonrole(self):
|
||||||
IPAddress.objects.create(address=IPNetwork('192.0.2.1/24'), role=IPAddressRoleChoices.ROLE_VIP)
|
IPAddress.objects.create(address=IPNetwork('192.0.2.1/24'), role=IPAddressRoleChoices.ROLE_VIP)
|
||||||
duplicate_ip = IPAddress(address=IPNetwork('192.0.2.1/24'))
|
duplicate_ip = IPAddress(address=IPNetwork('192.0.2.1/24'))
|
||||||
self.assertRaises(ValidationError, duplicate_ip.clean)
|
self.assertRaises(ValidationError, duplicate_ip.clean)
|
||||||
|
|
||||||
@override_settings(ENFORCE_GLOBAL_UNIQUE=True)
|
|
||||||
def test_duplicate_nonunique_role(self):
|
def test_duplicate_nonunique_role(self):
|
||||||
IPAddress.objects.create(address=IPNetwork('192.0.2.1/24'), role=IPAddressRoleChoices.ROLE_VIP)
|
IPAddress.objects.create(address=IPNetwork('192.0.2.1/24'), role=IPAddressRoleChoices.ROLE_VIP)
|
||||||
IPAddress.objects.create(address=IPNetwork('192.0.2.1/24'), role=IPAddressRoleChoices.ROLE_VIP)
|
IPAddress.objects.create(address=IPNetwork('192.0.2.1/24'), role=IPAddressRoleChoices.ROLE_VIP)
|
||||||
|
@ -66,7 +66,7 @@ PARAMS = (
|
|||||||
ConfigParam(
|
ConfigParam(
|
||||||
name='ENFORCE_GLOBAL_UNIQUE',
|
name='ENFORCE_GLOBAL_UNIQUE',
|
||||||
label=_('Globally unique IP space'),
|
label=_('Globally unique IP space'),
|
||||||
default=False,
|
default=True,
|
||||||
description=_("Enforce unique IP addressing within the global table"),
|
description=_("Enforce unique IP addressing within the global table"),
|
||||||
field=forms.BooleanField
|
field=forms.BooleanField
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user