From 0820eb65b57456d56c153a40bec9ebbb36df9691 Mon Sep 17 00:00:00 2001 From: Tommaso Bailetti Date: Fri, 15 Mar 2024 10:26:41 +0100 Subject: [PATCH 1/2] feat: added fqdn-changed event when setting fqdn --- .../node/actions/set-fqdn/30send_event | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 core/imageroot/var/lib/nethserver/node/actions/set-fqdn/30send_event diff --git a/core/imageroot/var/lib/nethserver/node/actions/set-fqdn/30send_event b/core/imageroot/var/lib/nethserver/node/actions/set-fqdn/30send_event new file mode 100755 index 000000000..027aad0f3 --- /dev/null +++ b/core/imageroot/var/lib/nethserver/node/actions/set-fqdn/30send_event @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + +# +# Copyright (C) 2024 Nethesis S.r.l. +# SPDX-License-Identifier: GPL-3.0-or-later +# + +import json +import os +import sys + +import agent + +request = json.load(sys.stdin) + +redis_client = agent.redis_connect(privileged=True) +redis_client.publish(f'{os.getenv("AGENT_ID")}/event/fqdn-changed', json.dumps({ + "hostname": request["hostname"], + "domain": request["domain"], + "node": int(os.getenv("NODE_ID")), +})) From adab15e5a9cc2f809b8f46296f15ed7a7ff46ccc Mon Sep 17 00:00:00 2001 From: Tommaso Bailetti Date: Fri, 15 Mar 2024 10:47:32 +0100 Subject: [PATCH 2/2] docs: added documentation about new event --- docs/core/events.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/core/events.md b/docs/core/events.md index c35d11ef4..300f01f97 100644 --- a/docs/core/events.md +++ b/docs/core/events.md @@ -39,6 +39,11 @@ Events fired by the `cluster` agent (i.e. channel is `cluster/event/ - `leader-changed`: a node was promoted to leader. The `node_id` attribute indicates the new leader, and `endpoint` its public Wireguard VPN endpoint address +## Node events + +Events fired by the `node` agent (i.e. channel is `node//event/`): +- `fqdn-changed`: the node FQDN has changed. The `hostname` and `domain` attribute describe the new FQDN, while the `node` attribute contains the node ID that originated the event + ## Signaling events To signal an event, just [PUBLISH](https://redis.io/commands/PUBLISH) a message to the channel.