Déclaration à agent1 via MQTT (agents/register) au démarrage

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
root
2026-03-07 16:55:55 +00:00
parent e4ec487287
commit 60099a5125
+13
View File
@@ -46,6 +46,19 @@ def start_mqtt():
client_id=MQTT_CLIENT + "_pub") client_id=MQTT_CLIENT + "_pub")
_mqtt_pub.connect(MQTT_HOST, MQTT_PORT) _mqtt_pub.connect(MQTT_HOST, MQTT_PORT)
_mqtt_pub.loop_start() _mqtt_pub.loop_start()
register_to_agent1()
def register_to_agent1():
"""Publie une déclaration de mise en ligne sur agents/register."""
import json as _json
payload = _json.dumps({
"agent" : MQTT_CLIENT,
"jid" : XMPP_JID,
"mqtt_inbox": cfg["mqtt_inbox"],
"speciality": "Déploiement d'agents : installe et configure d'autres agents sur des machines distantes ou locales via SSH",
})
mqtt_publish("agents/register", payload)
print("[REGISTER] Déclaration envoyée à agent1.")
def notify_agent1(agent_type: str, host: str, xmpp_jid: str, mqtt_inbox: str): def notify_agent1(agent_type: str, host: str, xmpp_jid: str, mqtt_inbox: str):
"""Informe agent1 du nouveau déploiement.""" """Informe agent1 du nouveau déploiement."""