fix: printer default site and no automatic device type creation

- Load sites with the device roles so the default site can be chosen before the first scan
- Printers without site and tenant in the mapping dialog go to the default site instead of being dropped
- Never create printer device types or manufacturers; only existing or manually mapped types are used

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
MrBlakeandClaude Opus 5.5 committed 2026-11-18 15:10:50 +01:00
1 parent b047278987
commit 698086a6aa
4 files changed
+73 -17

No files matched your search

+14
View File
@@ -398,6 +398,20 @@ class PrinterSyncEngine(APSyncEngine):
def _mapped_type(self, printer):
return self.type_map.get(model_key(printer))
# Printer device types are never created: only existing or manually chosen ones are used.
def _manufacturer(self, name, report, dry_run):
return None
def _device_type(self, manufacturer_name, manufacturer_id, model, report, dry_run):
hp = "hewlett-packard" if manufacturer_name.casefold() == "hp" else ""
found = next((row["id"] for row in self.device_types if row["model"].casefold() == model.casefold()
and row["manufacturer"].casefold() in (manufacturer_name.casefold(), hp)), None)
if found is None:
raise PrinterError(f"Gerätetyp „{manufacturer_name} {model}“ fehlt in NetBox – bitte unter "
"„Modelle …“ einen vorhandenen Gerätetyp wählen")
return found
def _known_devices(self, scope):
if not self.role_id:
return []