feat: offline mode with JSON export/import
Collect VMs and switch data without NetBox, export them to a credential-free .nbsync.json file and import it later where NetBox is reachable. Toggled by a global sidebar checkbox. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
c3b5fb547e
commit
52f1e4b5f1
14 files changed
+437
-33
No files matched your search
@@ -772,11 +772,21 @@ def sync_snapshot_to_netbox(nb, config, snapshot, create_cables=True, dry_run=Fa
|
||||
device-type templates and manual corrections in NetBox are preserved.
|
||||
"""
|
||||
report = _new_report()
|
||||
device_id = int(config["device_id"])
|
||||
device = nb.dcim.devices.get(device_id)
|
||||
if not device:
|
||||
report["errors"].append(f"NetBox-Gerät #{device_id} existiert nicht mehr")
|
||||
return report
|
||||
if config.get("device_id"):
|
||||
device_id = int(config["device_id"])
|
||||
device = nb.dcim.devices.get(device_id)
|
||||
if not device:
|
||||
report["errors"].append(f"NetBox-Gerät #{device_id} existiert nicht mehr")
|
||||
return report
|
||||
else:
|
||||
# Switches captured in offline mode are only known by name.
|
||||
matches = list(nb.dcim.devices.filter(name=config["name"]))
|
||||
if len(matches) != 1:
|
||||
report["errors"].append(f"NetBox-Gerät „{config['name']}“ " +
|
||||
("nicht gefunden" if not matches else "ist nicht eindeutig"))
|
||||
return report
|
||||
device = matches[0]
|
||||
device_id = device.id
|
||||
tenant_id = related_id(device, "tenant")
|
||||
existing = _device_interfaces(nb, device_id)
|
||||
records = {}
|
||||
|
||||
Reference in new issue
Block a user