/opt/netbox/report.py
class DescriptionsReport(Script):
    class Meta:
        name = "Description prüfen"
        description = "Prüft, ob bei allen aktiven Devices und VMs eine Beschreibung angegeben ist."

    def test_device_descriptions(self):
        """Prüft alle aktiven Devices auf eine vorhandene Beschreibung."""
        active_devices = Device.objects.filter(status="active")
        for device in active_devices:
            if device.device_type.is_child_device:
                self.log_success("Child Device übersprungen.", obj=device)
                continue

            # strip() entfernt eventuelle Leerzeichen. Wenn das Feld leer ist, ist der String False.
            if not device.description or not device.description.strip():
                self.log_failure("Device Beschreibung ist leer.", obj=device)
            else:
                self.log_success("Beschreibung vorhanden.", obj=device)

    def test_vm_descriptions(self):
        """Prüft alle aktiven virtuellen Maschinen auf eine vorhandene Beschreibung."""
        active_vms = VirtualMachine.objects.filter(status="active")
        for vm in active_vms:
            if not vm.description or not vm.description.strip():
                self.log_failure("Virtual Machine Beschreibung ist leer.", obj=vm)
            else:
                self.log_success("Beschreibung vorhanden.", obj=vm)