Skip to content

Commit

Permalink
Fixes netbox-community#397: Only include child IPs which belong to th…
Browse files Browse the repository at this point in the history
…e same VRF as the parent prefix
  • Loading branch information
jeremystretch committed Jul 28, 2016
1 parent b081fe9 commit 6550dd3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions netbox/ipam/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ def prefix(request, pk):
aggregate = None

# Count child IP addresses
ipaddress_count = IPAddress.objects.filter(address__net_contained_or_equal=str(prefix.prefix)).count()
ipaddress_count = IPAddress.objects.filter(vrf=prefix.vrf, address__net_contained_or_equal=str(prefix.prefix))\
.count()

# Parent prefixes table
parent_prefixes = Prefix.objects.filter(vrf=prefix.vrf, prefix__net_contains=str(prefix.prefix))\
Expand Down Expand Up @@ -359,7 +360,7 @@ def prefix_ipaddresses(request, pk):
prefix = get_object_or_404(Prefix.objects.all(), pk=pk)

# Find all IPAddresses belonging to this Prefix
ipaddresses = IPAddress.objects.filter(address__net_contained_or_equal=str(prefix.prefix))\
ipaddresses = IPAddress.objects.filter(vrf=prefix.vrf, address__net_contained_or_equal=str(prefix.prefix))\
.select_related('vrf', 'interface__device', 'primary_ip4_for', 'primary_ip6_for')

ip_table = tables.IPAddressTable(ipaddresses)
Expand Down

0 comments on commit 6550dd3

Please sign in to comment.