mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Merge branch 'develop' into feature
This commit is contained in:
@@ -22,6 +22,6 @@ class Command(BaseCommand):
|
||||
for vrf in VRF.objects.all():
|
||||
vrf_count = Prefix.objects.filter(vrf=vrf).count()
|
||||
self.stdout.write(f'VRF {vrf}: {vrf_count} prefixes...')
|
||||
rebuild_prefixes(vrf)
|
||||
rebuild_prefixes(vrf.pk)
|
||||
|
||||
self.stdout.write(self.style.SUCCESS('Finished.'))
|
||||
|
@@ -20,7 +20,7 @@ def populate_prefix_hierarchy(apps, schema_editor):
|
||||
|
||||
# Iterate through all VRFs, rebuilding each
|
||||
for vrf in VRF.objects.all():
|
||||
rebuild_prefixes(vrf)
|
||||
rebuild_prefixes(vrf.pk)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
@@ -311,16 +311,6 @@ class Prefix(PrimaryModel):
|
||||
'prefix': "Cannot create prefix with /0 mask."
|
||||
})
|
||||
|
||||
# Disallow host masks
|
||||
if self.prefix.version == 4 and self.prefix.prefixlen == 32:
|
||||
raise ValidationError({
|
||||
'prefix': "Cannot create host addresses (/32) as prefixes. Create an IPv4 address instead."
|
||||
})
|
||||
elif self.prefix.version == 6 and self.prefix.prefixlen == 128:
|
||||
raise ValidationError({
|
||||
'prefix': "Cannot create host addresses (/128) as prefixes. Create an IPv6 address instead."
|
||||
})
|
||||
|
||||
# Enforce unique IP space (if applicable)
|
||||
if (self.vrf is None and settings.ENFORCE_GLOBAL_UNIQUE) or (self.vrf and self.vrf.enforce_unique):
|
||||
duplicate_prefixes = self.get_duplicates()
|
||||
@@ -431,8 +421,8 @@ class Prefix(PrimaryModel):
|
||||
child_ips = netaddr.IPSet([ip.address.ip for ip in self.get_child_ips()])
|
||||
available_ips = prefix - child_ips
|
||||
|
||||
# IPv6, pool, or IPv4 /31 sets are fully usable
|
||||
if self.family == 6 or self.is_pool or self.prefix.prefixlen == 31:
|
||||
# IPv6, pool, or IPv4 /31-/32 sets are fully usable
|
||||
if self.family == 6 or self.is_pool or (self.family == 4 and self.prefix.prefixlen >= 31):
|
||||
return available_ips
|
||||
|
||||
# For "normal" IPv4 prefixes, omit first and last addresses
|
||||
|
@@ -522,7 +522,7 @@ class IPAddressView(generic.ObjectView):
|
||||
# Parent prefixes table
|
||||
parent_prefixes = Prefix.objects.restrict(request.user, 'view').filter(
|
||||
vrf=instance.vrf,
|
||||
prefix__net_contains=str(instance.address.ip)
|
||||
prefix__net_contains_or_equals=str(instance.address.ip)
|
||||
).prefetch_related(
|
||||
'site', 'role'
|
||||
)
|
||||
|
Reference in New Issue
Block a user