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")), +})) 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.