сонет вайб 5

This commit is contained in:
dv 2026-04-08 13:35:12 +03:00
parent b59f0222f0
commit 58c36da2ae

View file

@ -646,15 +646,10 @@ async def discover_via_ssh(
result.errors.append(f"SSH to {rack_host} failed: {exc}")
rack_ssh_ok = False
config_text = None
logger.info(f"[ssh_discovery] Processing rack {rack_host} ({rack_hostname})")
logger.info(f"[ssh_discovery] Processing rack {rack_host} ({rack_hostname}), ssh_ok={rack_ssh_ok}, in_db={existing_rack_pc is not None}")
# Reuse existing_rack_pc (queried before SSH) — same identity map object
existing_rack = existing_rack_pc
try:
existing_rack = (await db.execute(
select(Device).where(
Device.object_id == obj.id,
Device.ip == rack_host,
)
)).scalar_one_or_none()
if existing_rack is None:
db.add(Device(
object_id=obj.id,
@ -724,7 +719,10 @@ async def discover_via_ssh(
role="other",
))
if not rack_ssh_ok:
await db.flush()
try:
await db.flush()
except Exception as exc:
result.errors.append(f"Flush error for offline rack {rack_host}: {exc}")
continue # no config to parse
# Get all rack IPs to exclude them from device discovery