/opt/netbox/report.py
class PlatformReport(Script):
    class Meta:
        name = "Platform prüfen"
        description = "Prüft, ob eine Platform angegeben ist."

    def test_device_platforms(self):
        """Prüft alle aktiven Devices auf eine zugewiesene Plattform."""
        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

            if device.platform_id is None:
                self.log_failure("Device hat keine Plattform zugewiesen.", obj=device)
            else:
                self.log_success("Plattform zugewiesen.", obj=device)

    def test_vm_platforms(self):
        """Prüft alle aktiven virtuellen Maschinen auf eine zugewiesene Plattform."""
        active_vms = VirtualMachine.objects.filter(status="active")
        for vm in active_vms:
            if vm.platform_id is None:
                self.log_failure("Virtual Machine hat keine Plattform zugewiesen.", obj=vm)
            else:
                self.log_success("Plattform zugewiesen.", obj=vm)