This commit is contained in:
2026-03-09 15:14:31 +02:00
parent a963a9e0f7
commit fc476be2cc

View File

@@ -447,7 +447,7 @@ async def main():
"mac": "-", "mac": "-",
"mac_norm": None, "mac_norm": None,
"fw": "-", "fw": "-",
"host": None, "device_hostname": None,
"iface_id": None, "iface_id": None,
"nb_lookup_result": "not_attempted", "nb_lookup_result": "not_attempted",
"ignored": False, "ignored": False,
@@ -529,7 +529,7 @@ async def main():
event["action_state"] = action_state event["action_state"] = action_state
if host: if host:
event["nb_lookup_result"] = "resolved" event["nb_lookup_result"] = "resolved"
host_suffix = f" host={host}" host_suffix = f" device_hostname={host}"
elif iface_id: elif iface_id:
event["nb_lookup_result"] = "iface_only" event["nb_lookup_result"] = "iface_only"
else: else:
@@ -561,7 +561,7 @@ async def main():
await log_event(event) await log_event(event)
async with print_lock: async with print_lock:
print( print(
f"[{ts()}] device is not ready because of action_state host={host} action_state={action_state_str}", f"[{ts()}] device is not ready because of action_state device_hostname={host} action_state={action_state_str}",
file=sys.stdout, file=sys.stdout,
flush=True, flush=True,
) )
@@ -584,10 +584,10 @@ async def main():
if not has_action_next: if not has_action_next:
event["decision"] = "no_action" event["decision"] = "no_action"
event["decision_reason"] = "no action_next for host" event["decision_reason"] = "no action_next for device_hostname"
# User-requested behavior: if no action -> just shoot a message to stdout and we're ok # User-requested behavior: if no action -> just shoot a message to stdout and we're ok
async with print_lock: async with print_lock:
print(f"[{ts()}] no action_next for host={host}", file=sys.stdout, flush=True) print(f"[{ts()}] no action_next for device_hostname={host}", file=sys.stdout, flush=True)
else: else:
# Compare action_last with action_next (strings) # Compare action_last with action_next (strings)
action_last_str = None action_last_str = None
@@ -620,7 +620,7 @@ async def main():
event["decision_reason"] = f"sot_ts is recent age_s={_age}" event["decision_reason"] = f"sot_ts is recent age_s={_age}"
async with print_lock: async with print_lock:
print( print(
f"[{ts()}] skip action_next because sot_ts is recent host={host} task={action_next_str} age_s={_age} sot_ts={_st}", f"[{ts()}] skip action_next because sot_ts is recent device_hostname={host} task={action_next_str} age_s={_age} sot_ts={_st}",
file=sys.stdout, file=sys.stdout,
flush=True, flush=True,
) )
@@ -649,7 +649,7 @@ async def main():
event["decision_reason"] = "action_next cooldown active" event["decision_reason"] = "action_next cooldown active"
async with print_lock: async with print_lock:
print( print(
f"[{ts()}] cooldown action_next for host={host} task={action_next_str}", f"[{ts()}] cooldown action_next for device_hostname={host} task={action_next_str}",
file=sys.stdout, file=sys.stdout,
flush=True, flush=True,
) )
@@ -702,7 +702,7 @@ async def main():
event["decision"] = "publish_failed" event["decision"] = "publish_failed"
event["decision_reason"] = f"rmq publish http={code}" event["decision_reason"] = f"rmq publish http={code}"
event["publish_result"] = "failed" event["publish_result"] = "failed"
await log_status(f"[{ts()}] rmq: publish http={code} host={host}") await log_status(f"[{ts()}] rmq: publish http={code} device_hostname={host}")
else: else:
routed = False routed = False
try: try:
@@ -718,7 +718,7 @@ async def main():
event["decision"] = "publish_failed" event["decision"] = "publish_failed"
event["decision_reason"] = "rmq immediate publish routed=false" event["decision_reason"] = "rmq immediate publish routed=false"
event["publish_result"] = "failed" event["publish_result"] = "failed"
await log_status(f"[{ts()}] rmq: publish immediate routed=false host={host}") await log_status(f"[{ts()}] rmq: publish immediate routed=false device_hostname={host}")
# ---------------------- # ----------------------
if publish_ok: if publish_ok:
@@ -740,9 +740,9 @@ async def main():
timeout=NB_TIMEOUT, timeout=NB_TIMEOUT,
) )
if pcode != 200: if pcode != 200:
await log_status(f"[{ts()}] nb: action_last/timestamp patch http={pcode} host={host} dev_id={dev_id}") await log_status(f"[{ts()}] nb: action_last/timestamp patch http={pcode} device_hostname={host} dev_id={dev_id}")
except Exception as e: except Exception as e:
await log_status(f"[{ts()}] nb: action_last/timestamp patch error host={host!r} dev_id={dev_id!r} err={e!r}") await log_status(f"[{ts()}] nb: action_last/timestamp patch error device_hostname={host!r} dev_id={dev_id!r} err={e!r}")
bell_prefix = "\a" * 3 bell_prefix = "\a" * 3
else: else:
@@ -794,7 +794,7 @@ async def main():
event["decision"] = "publish_failed" event["decision"] = "publish_failed"
event["decision_reason"] = f"rmq publish http={code}" event["decision_reason"] = f"rmq publish http={code}"
event["publish_result"] = "failed" event["publish_result"] = "failed"
await log_status(f"[{ts()}] rmq: publish http={code} host={host}") await log_status(f"[{ts()}] rmq: publish http={code} device_hostname={host}")
else: else:
routed = False routed = False
try: try:
@@ -809,7 +809,7 @@ async def main():
event["decision"] = "publish_failed" event["decision"] = "publish_failed"
event["decision_reason"] = "rmq immediate publish routed=false" event["decision_reason"] = "rmq immediate publish routed=false"
event["publish_result"] = "failed" event["publish_result"] = "failed"
await log_status(f"[{ts()}] rmq: publish immediate routed=false host={host}") await log_status(f"[{ts()}] rmq: publish immediate routed=false device_hostname={host}")
# ---------------------- # ----------------------
if publish_ok: if publish_ok:
@@ -831,9 +831,9 @@ async def main():
timeout=NB_TIMEOUT, timeout=NB_TIMEOUT,
) )
if pcode != 200: if pcode != 200:
await log_status(f"[{ts()}] nb: action_last/timestamp patch http={pcode} host={host} dev_id={dev_id}") await log_status(f"[{ts()}] nb: action_last/timestamp patch http={pcode} device_hostname={host} dev_id={dev_id}")
except Exception as e: except Exception as e:
await log_status(f"[{ts()}] nb: action_last/timestamp patch error host={host!r} dev_id={dev_id!r} err={e!r}") await log_status(f"[{ts()}] nb: action_last/timestamp patch error device_hostname={host!r} dev_id={dev_id!r} err={e!r}")
bell_prefix = "" bell_prefix = ""