Skip to content

Commit

Permalink
feat: fire fqdn-changed event when fqdn changes (#613)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tbaile authored Mar 18, 2024
1 parent 1175385 commit 340ecd9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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")),
}))
5 changes: 5 additions & 0 deletions docs/core/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ Events fired by the `cluster` agent (i.e. channel is `cluster/event/<event name>
- `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/<node id>/event/<event name>`):
- `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.
Expand Down

0 comments on commit 340ecd9

Please sign in to comment.