1514
This commit is contained in:
@@ -447,7 +447,7 @@ async def main():
|
||||
"mac": "-",
|
||||
"mac_norm": None,
|
||||
"fw": "-",
|
||||
"host": None,
|
||||
"device_hostname": None,
|
||||
"iface_id": None,
|
||||
"nb_lookup_result": "not_attempted",
|
||||
"ignored": False,
|
||||
@@ -529,7 +529,7 @@ async def main():
|
||||
event["action_state"] = action_state
|
||||
if host:
|
||||
event["nb_lookup_result"] = "resolved"
|
||||
host_suffix = f" host={host}"
|
||||
host_suffix = f" device_hostname={host}"
|
||||
elif iface_id:
|
||||
event["nb_lookup_result"] = "iface_only"
|
||||
else:
|
||||
@@ -561,7 +561,7 @@ async def main():
|
||||
await log_event(event)
|
||||
async with print_lock:
|
||||
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,
|
||||
flush=True,
|
||||
)
|
||||
@@ -584,10 +584,10 @@ async def main():
|
||||
|
||||
if not has_action_next:
|
||||
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
|
||||
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:
|
||||
# Compare action_last with action_next (strings)
|
||||
action_last_str = None
|
||||
@@ -620,7 +620,7 @@ async def main():
|
||||
event["decision_reason"] = f"sot_ts is recent age_s={_age}"
|
||||
async with print_lock:
|
||||
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,
|
||||
flush=True,
|
||||
)
|
||||
@@ -649,7 +649,7 @@ async def main():
|
||||
event["decision_reason"] = "action_next cooldown active"
|
||||
async with print_lock:
|
||||
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,
|
||||
flush=True,
|
||||
)
|
||||
@@ -702,7 +702,7 @@ async def main():
|
||||
event["decision"] = "publish_failed"
|
||||
event["decision_reason"] = f"rmq publish http={code}"
|
||||
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:
|
||||
routed = False
|
||||
try:
|
||||
@@ -718,7 +718,7 @@ async def main():
|
||||
event["decision"] = "publish_failed"
|
||||
event["decision_reason"] = "rmq immediate publish routed=false"
|
||||
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:
|
||||
@@ -740,9 +740,9 @@ async def main():
|
||||
timeout=NB_TIMEOUT,
|
||||
)
|
||||
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:
|
||||
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
|
||||
else:
|
||||
@@ -794,7 +794,7 @@ async def main():
|
||||
event["decision"] = "publish_failed"
|
||||
event["decision_reason"] = f"rmq publish http={code}"
|
||||
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:
|
||||
routed = False
|
||||
try:
|
||||
@@ -809,7 +809,7 @@ async def main():
|
||||
event["decision"] = "publish_failed"
|
||||
event["decision_reason"] = "rmq immediate publish routed=false"
|
||||
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:
|
||||
@@ -831,9 +831,9 @@ async def main():
|
||||
timeout=NB_TIMEOUT,
|
||||
)
|
||||
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:
|
||||
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 = ""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user