Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34b1391ff0 | ||
|
|
340f404f94 | ||
|
|
f1af9f8f86 | ||
|
|
2fb6ac38ec |
No files matched your search
@@ -102,7 +102,8 @@ vSphere and Proxmox VE, HPE/Aruba switches and Windows clients in NetBox.
|
|||||||
- Sophos sites are mapped to NetBox sites (suggested by name, stored per
|
- Sophos sites are mapped to NetBox sites (suggested by name, stored per
|
||||||
profile); the site is optional – APs without one go to a default site, since
|
profile); the site is optional – APs without one go to a default site, since
|
||||||
NetBox requires a site for every device. The tenant is mandatory and chosen
|
NetBox requires a site for every device. The tenant is mandatory and chosen
|
||||||
deliberately per Sophos site – it is never preselected
|
deliberately per Sophos site – it is never preselected. Sophos sites left without site and tenant are
|
||||||
|
ignored (stored per profile) and not transferred
|
||||||
- New APs are created with Sophos device type, role, site, serial number,
|
- New APs are created with Sophos device type, role, site, serial number,
|
||||||
firmware, interface with MAC and IP address (primary IPv4); existing ones get
|
firmware, interface with MAC and IP address (primary IPv4); existing ones get
|
||||||
missing serial numbers and tenants, optionally the Sophos name. Preview before
|
missing serial numbers and tenants, optionally the Sophos name. Preview before
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#define AppName "NetBox Synchronizer"
|
#define AppName "NetBox Synchronizer"
|
||||||
#ifndef AppVersion
|
#ifndef AppVersion
|
||||||
#define AppVersion "4.10.3"
|
#define AppVersion "4.10.5"
|
||||||
#endif
|
#endif
|
||||||
#define AppPublisher "Louis-Alexander Kerst"
|
#define AppPublisher "Louis-Alexander Kerst"
|
||||||
#define AppExeName "NetBoxSynchronizer.exe"
|
#define AppExeName "NetBoxSynchronizer.exe"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"""NetBox Synchronizer – VMs, switches and clients from the field into NetBox."""
|
"""NetBox Synchronizer – VMs, switches and clients from the field into NetBox."""
|
||||||
|
|
||||||
APP_NAME = "NetBox Synchronizer"
|
APP_NAME = "NetBox Synchronizer"
|
||||||
APP_VERSION = "4.10.3"
|
APP_VERSION = "4.10.5"
|
||||||
APP_PUBLISHER = "Louis-Alexander Kerst"
|
APP_PUBLISHER = "Louis-Alexander Kerst"
|
||||||
APP_USER_MODEL_ID = "Louis-AlexanderKerst.NetBoxSynchronizer"
|
APP_USER_MODEL_ID = "Louis-AlexanderKerst.NetBoxSynchronizer"
|
||||||
|
|
||||||
|
|||||||
@@ -976,12 +976,14 @@ class SwitchMappingDialog(_Dialog):
|
|||||||
chosen = combo.currentData()
|
chosen = combo.currentData()
|
||||||
target = "" if chosen == self.NEW else chosen
|
target = "" if chosen == self.NEW else chosen
|
||||||
mapping = result[switch["id"]]["interface_map"]
|
mapping = result[switch["id"]]["interface_map"]
|
||||||
if target and (switch["id"], target) in used:
|
# Stack members have their own devices, so equal names are only a clash on the same device.
|
||||||
|
key = (switch["id"], item.get("owner_id"), target)
|
||||||
|
if target and key in used:
|
||||||
self.show_error(f"{switch['name']}: „{target}“ ist mehreren Schnittstellen zugeordnet "
|
self.show_error(f"{switch['name']}: „{target}“ ist mehreren Schnittstellen zugeordnet "
|
||||||
f"({used[(switch['id'], target)]}, {item['name']}).")
|
f"({used[key]}, {item['name']}).")
|
||||||
return
|
return
|
||||||
if target:
|
if target:
|
||||||
used[(switch["id"], target)] = item["name"]
|
used[key] = item["name"]
|
||||||
# Plain name matches stay automatic; everything else is remembered.
|
# Plain name matches stay automatic; everything else is remembered.
|
||||||
if item["method"] == "name" and target == item["netbox_name"]:
|
if item["method"] == "name" and target == item["netbox_name"]:
|
||||||
mapping.pop(item["name"], None)
|
mapping.pop(item["name"], None)
|
||||||
|
|||||||
@@ -30,8 +30,10 @@ from netbox_sync.ui.widgets import (
|
|||||||
label,
|
label,
|
||||||
)
|
)
|
||||||
|
|
||||||
STATE_TEXT = {"new": "neu", "known": "in NetBox", "check": "prüfen", "netbox_only": "nur in NetBox"}
|
STATE_TEXT = {"new": "neu", "known": "in NetBox", "check": "prüfen", "netbox_only": "nur in NetBox",
|
||||||
STATE_DOT = {"new": "accent", "known": "success", "check": "warning", "netbox_only": "text_faint"}
|
"ignored": "ignoriert"}
|
||||||
|
STATE_DOT = {"new": "accent", "known": "success", "check": "warning", "netbox_only": "text_faint",
|
||||||
|
"ignored": "text_faint"}
|
||||||
ROLE_HINTS = ("access point", "accesspoint", "access-point", "wlan", "wifi", "ap")
|
ROLE_HINTS = ("access point", "accesspoint", "access-point", "wlan", "wifi", "ap")
|
||||||
|
|
||||||
|
|
||||||
@@ -49,7 +51,8 @@ class SiteMappingDialog(_Dialog):
|
|||||||
def __init__(self, parent, rows, sites, tenants):
|
def __init__(self, parent, rows, sites, tenants):
|
||||||
super().__init__(parent, "Standorte & Mandanten zuordnen",
|
super().__init__(parent, "Standorte & Mandanten zuordnen",
|
||||||
"Der Standort ist optional – APs ohne Zuordnung kommen an den Standard-Standort, weil NetBox "
|
"Der Standort ist optional – APs ohne Zuordnung kommen an den Standard-Standort, weil NetBox "
|
||||||
"für jedes Gerät einen Standort verlangt. Der Mandant ist Pflicht und wird bewusst gewählt.",
|
"für jedes Gerät einen Standort verlangt. Der Mandant ist Pflicht und wird bewusst gewählt. Zeilen ohne "
|
||||||
|
"Standort und ohne Mandant werden ignoriert.",
|
||||||
width=860)
|
width=860)
|
||||||
self.resize(980, 620)
|
self.resize(980, 620)
|
||||||
site_items = [("– kein Standort (Standard-Standort) –", 0)] + [
|
site_items = [("– kein Standort (Standard-Standort) –", 0)] + [
|
||||||
@@ -88,7 +91,7 @@ class SiteMappingDialog(_Dialog):
|
|||||||
def accept(self):
|
def accept(self):
|
||||||
result = {}
|
result = {}
|
||||||
for key, site, tenant in self.rows:
|
for key, site, tenant in self.rows:
|
||||||
if tenant.valid_data() is None:
|
if tenant.valid_data() is None and site.valid_data():
|
||||||
self.show_error(f"Bitte für „{key[1]}“ einen Mandanten wählen.")
|
self.show_error(f"Bitte für „{key[1]}“ einen Mandanten wählen.")
|
||||||
return
|
return
|
||||||
result[key] = {"site": site.valid_data() or None, "tenant": tenant.valid_data()}
|
result[key] = {"site": site.valid_data() or None, "tenant": tenant.valid_data()}
|
||||||
@@ -301,9 +304,11 @@ class AccessPointsPage(Page):
|
|||||||
stored = (settings.get("ap_sites") or {}).get(ap_key(ap)) or (settings.get("site_map") or {}).get(
|
stored = (settings.get("ap_sites") or {}).get(ap_key(ap)) or (settings.get("site_map") or {}).get(
|
||||||
ap["site_hint"])
|
ap["site_hint"])
|
||||||
if stored:
|
if stored:
|
||||||
return dict(placement_value(stored), stored=True)
|
value = placement_value(stored)
|
||||||
|
# neither site nor tenant: the user chose to leave these APs out
|
||||||
|
return dict(value, stored=True, ignored=not value["site"] and not value["tenant"])
|
||||||
site = self.engine.suggest_site(ap["site_hint"]) if self.engine else None
|
site = self.engine.suggest_site(ap["site_hint"]) if self.engine else None
|
||||||
return {"site": site, "tenant": None, "stored": False}
|
return {"site": site, "tenant": None, "stored": False, "ignored": False}
|
||||||
|
|
||||||
def _tenant_for(self, placement):
|
def _tenant_for(self, placement):
|
||||||
return placement.get("tenant")
|
return placement.get("tenant")
|
||||||
@@ -327,6 +332,8 @@ class AccessPointsPage(Page):
|
|||||||
site_name = getattr(site, "name", "") or self._site_name(getattr(site, "id", site))
|
site_name = getattr(site, "name", "") or self._site_name(getattr(site, "id", site))
|
||||||
tenant_name = getattr(getattr(device, "tenant", None), "name", "") or self._tenant_name(
|
tenant_name = getattr(getattr(device, "tenant", None), "name", "") or self._tenant_name(
|
||||||
related_id(device, "tenant"))
|
related_id(device, "tenant"))
|
||||||
|
elif self.engine and self._placement(ap)["ignored"]:
|
||||||
|
site_name = ""
|
||||||
elif self.engine:
|
elif self.engine:
|
||||||
placement = self._placement(ap)
|
placement = self._placement(ap)
|
||||||
site_id = placement["site"] or default_site
|
site_id = placement["site"] or default_site
|
||||||
@@ -335,7 +342,7 @@ class AccessPointsPage(Page):
|
|||||||
tenant_name = self._tenant_name(self._tenant_for(placement))
|
tenant_name = self._tenant_name(self._tenant_for(placement))
|
||||||
else:
|
else:
|
||||||
site_name = ""
|
site_name = ""
|
||||||
state = "new" if not device else ("check" if ap["issues"] else "known")
|
state = ("ignored" if self.engine and self._placement(ap)["ignored"] else "new") if not device else ("check" if ap["issues"] else "known")
|
||||||
rows.append(dict(ap, key=ap_key(ap), state=state if self.engine else "", site_id=site_id,
|
rows.append(dict(ap, key=ap_key(ap), state=state if self.engine else "", site_id=site_id,
|
||||||
netbox_site=site_name, tenant=tenant_name or "",
|
netbox_site=site_name, tenant=tenant_name or "",
|
||||||
netbox_device=device.name if device else "", method=ap.get("method", "")))
|
netbox_device=device.name if device else "", method=ap.get("method", "")))
|
||||||
@@ -360,6 +367,8 @@ class AccessPointsPage(Page):
|
|||||||
if self.engine:
|
if self.engine:
|
||||||
parts += [f"{counts['known']} in NetBox", f"{counts['new']} neu", f"{counts['check']} zu prüfen",
|
parts += [f"{counts['known']} in NetBox", f"{counts['new']} neu", f"{counts['check']} zu prüfen",
|
||||||
f"{counts['netbox_only']} nur in NetBox"]
|
f"{counts['netbox_only']} nur in NetBox"]
|
||||||
|
if counts["ignored"]:
|
||||||
|
parts.append(f"{counts['ignored']} ignoriert")
|
||||||
missing_sites = sum(1 for row in rows if row["state"] == "new" and not row.get("site_id"))
|
missing_sites = sum(1 for row in rows if row["state"] == "new" and not row.get("site_id"))
|
||||||
if missing_sites:
|
if missing_sites:
|
||||||
parts.append(f"{missing_sites} ohne Standort – Standard-Standort wählen")
|
parts.append(f"{missing_sites} ohne Standort – Standard-Standort wählen")
|
||||||
@@ -412,14 +421,16 @@ class AccessPointsPage(Page):
|
|||||||
def sync(self):
|
def sync(self):
|
||||||
if not self.engine or self.tasks.busy:
|
if not self.engine or self.tasks.busy:
|
||||||
return
|
return
|
||||||
new = self._new_aps()
|
new = [ap for ap in self._new_aps() if not self._placement(ap)["ignored"]]
|
||||||
role_id = self.role.valid_data()
|
role_id = self.role.valid_data()
|
||||||
if new and not role_id:
|
if new and not role_id:
|
||||||
widgets.message(self.window, "Geräterolle fehlt", "Für neue Access Points bitte eine Geräterolle wählen.",
|
widgets.message(self.window, "Geräterolle fehlt", "Für neue Access Points bitte eine Geräterolle wählen.",
|
||||||
"info")
|
"info")
|
||||||
return
|
return
|
||||||
if any(not self._placement(ap)["stored"] for ap in new) and not self.map_sites():
|
if any(not self._placement(ap)["stored"] for ap in new):
|
||||||
|
if not self.map_sites():
|
||||||
return
|
return
|
||||||
|
new = [ap for ap in new if not self._placement(ap)["ignored"]]
|
||||||
default_site = self.default_site.valid_data()
|
default_site = self.default_site.valid_data()
|
||||||
placements = {}
|
placements = {}
|
||||||
for ap in new:
|
for ap in new:
|
||||||
@@ -432,7 +443,8 @@ class AccessPointsPage(Page):
|
|||||||
"Gerät einen Standort – bitte oben einen Standard-Standort wählen.", "info",
|
"Gerät einen Standort – bitte oben einen Standard-Standort wählen.", "info",
|
||||||
"\n".join(homeless))
|
"\n".join(homeless))
|
||||||
return
|
return
|
||||||
engine, aps, rename = self.engine, list(self.aps), self.rename.isChecked()
|
engine, rename = self.engine, self.rename.isChecked()
|
||||||
|
aps = [ap for ap in self.aps if ap.get("device") or ap_key(ap) in placements]
|
||||||
|
|
||||||
def run(dry_run):
|
def run(dry_run):
|
||||||
return lambda ctx: engine.sync(aps, placements, role_id, rename, dry_run=dry_run, default_site=default_site)
|
return lambda ctx: engine.sync(aps, placements, role_id, rename, dry_run=dry_run, default_site=default_site)
|
||||||
|
|||||||
Reference in new issue
Block a user