Skip to content

Netbox Report give an error to find rack information #15628

Discussion options

You must be logged in to vote

Hi @candlerb ,

Thank you for your support, I have fixed the issue and used following script to fix the issue

from dcim.models import Rack, Device
from extras.reports import Report
from django.db.models import Count

def test_empty_rack(report, region):
    racks_data = Rack.objects.prefetch_related('devices').annotate(device_count=Count('devices')).filter(tenant__slug=region)
    for rack in racks_data:
        device_count = rack.device_count
        if device_count == 0:
            report.log_failure(rack, f" Rack {rack}  is Empty")
        else:
            report.log_success(rack)

class RackReport(Report):
    description =  (
    "Report to find empty racks"
    )
    def test_empt…

Replies: 4 comments 12 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
12 replies
@candlerb
Comment options

@nikunj-tele
Comment options

@nikunj-tele
Comment options

@nikunj-tele
Comment options

@candlerb
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by nikunj-tele
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants