фикс парсинга 3
This commit is contained in:
parent
b64198235d
commit
d9f62717ce
2 changed files with 70 additions and 53 deletions
|
|
@ -158,7 +158,10 @@ def parse_slave_check(config_text: str, master_ip: str, host: str) -> tuple[bool
|
|||
(is_slave, identifier, config_text) — config_text is passed through unchanged.
|
||||
"""
|
||||
parser = RawConfigParser(strict=False)
|
||||
try:
|
||||
parser.read_string(config_text)
|
||||
except _cp.Error as exc:
|
||||
logger.warning("[discovery] Config parse warning for %s: %s", host, exc)
|
||||
linking_cls = parser.get("plugin:linking", "cls", fallback="")
|
||||
linking_uri = parser.get("plugin:linking", "uri", fallback="")
|
||||
identifier = parser.get("caps.rack", "identifier", fallback="").strip()
|
||||
|
|
|
|||
|
|
@ -692,6 +692,7 @@ async def _discover_slave_racks(
|
|||
logger.info("[discovery] Checking slave candidate %s...", candidate_ip)
|
||||
await _emit("disc_action", {"message": f"Проверяем слейв-кандидата {candidate_ip}..."})
|
||||
|
||||
try:
|
||||
slave_config = await fetch_slave_config(candidate_ip, ssh_port, ssh_options, config_path)
|
||||
is_slave = False
|
||||
slave_identifier = ""
|
||||
|
|
@ -733,7 +734,7 @@ async def _discover_slave_racks(
|
|||
for found in slave_devices:
|
||||
await _upsert_plugin_device(
|
||||
db, obj, found,
|
||||
external_id="", # not used for slaves (is_slave=True path)
|
||||
external_id="",
|
||||
rack_id_mapping={},
|
||||
result=result,
|
||||
slave_rack_id=slave_rack_id,
|
||||
|
|
@ -744,6 +745,11 @@ async def _discover_slave_racks(
|
|||
await db.flush()
|
||||
except Exception as exc:
|
||||
result.errors.append(f"Flush error after slave {candidate_ip}: {exc}")
|
||||
logger.error("[discovery] Flush error after slave %s: %s", candidate_ip, exc)
|
||||
|
||||
except Exception as exc:
|
||||
result.errors.append(f"Slave candidate {candidate_ip}: {exc}")
|
||||
logger.error("[discovery] Error processing slave candidate %s: %s", candidate_ip, exc, exc_info=True)
|
||||
|
||||
|
||||
async def _ensure_slave_rack(
|
||||
|
|
@ -875,7 +881,11 @@ async def _discover_mikrotik(
|
|||
ip=mikrotik_ip, hostname="mikrotik", action="ERROR", reason=str(exc),
|
||||
category="router", role="other",
|
||||
))
|
||||
try:
|
||||
await db.flush()
|
||||
except Exception as exc:
|
||||
result.errors.append(f"Flush error after mikrotik upsert: {exc}")
|
||||
logger.error("[discovery] Flush error after mikrotik: %s", exc)
|
||||
|
||||
|
||||
async def _discover_proxmox(
|
||||
|
|
@ -934,7 +944,11 @@ async def _discover_proxmox(
|
|||
ip=proxmox_ip, hostname=hostname, action="ERROR", reason=str(exc),
|
||||
category="vm", role="other",
|
||||
))
|
||||
try:
|
||||
await db.flush()
|
||||
except Exception as exc:
|
||||
result.errors.append(f"Flush error after proxmox upsert: {exc}")
|
||||
logger.error("[discovery] Flush error after proxmox: %s", exc)
|
||||
|
||||
|
||||
# ── Summary logging ───────────────────────────────────────────────────────────
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue