Skip to content

Commit

Permalink
Fixes #467: Include prefixes and IPs which inherit tenancy from their…
Browse files Browse the repository at this point in the history
… VRF in tenant stats
  • Loading branch information
jeremystretch committed Aug 15, 2016
1 parent 13136d0 commit 78c3b25
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions netbox/tenancy/views.py
@@ -1,5 +1,5 @@
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.db.models import Count
from django.db.models import Count, Q
from django.shortcuts import get_object_or_404, render

from circuits.models import Circuit
Expand Down Expand Up @@ -59,8 +59,14 @@ def tenant(request, slug):
'rack_count': Rack.objects.filter(tenant=tenant).count(),
'device_count': Device.objects.filter(tenant=tenant).count(),
'vrf_count': VRF.objects.filter(tenant=tenant).count(),
'prefix_count': Prefix.objects.filter(tenant=tenant).count(),
'ipaddress_count': IPAddress.objects.filter(tenant=tenant).count(),
'prefix_count': Prefix.objects.filter(
Q(tenant=tenant) |
Q(tenant__isnull=True, vrf__tenant=tenant)
).count(),
'ipaddress_count': IPAddress.objects.filter(
Q(tenant=tenant) |
Q(tenant__isnull=True, vrf__tenant=tenant)
).count(),
'vlan_count': VLAN.objects.filter(tenant=tenant).count(),
'circuit_count': Circuit.objects.filter(tenant=tenant).count(),
}
Expand Down

0 comments on commit 78c3b25

Please sign in to comment.