56 const SaClmClusterNodeT *cluster_node, SaAisErrorT error);
57 static void clm_track_cb(
const SaClmClusterNotificationBufferT *notif_buffer,
58 SaUint32T num_members, SaAisErrorT error);
66 const SaClmClusterNodeT *cluster_node, SaAisErrorT error)
71 static void clm_track_cb(
const SaClmClusterNotificationBufferT *notif_buffer,
72 SaUint32T num_members, SaAisErrorT error)
75 unsigned int node_joined = 0;
77 ast_debug(1,
"Cluster membership changed. Number of members: %u\n", num_members);
79 for (i = 0; i < notif_buffer->numberOfItems; i++) {
80 SaClmClusterNotificationT *notif = notif_buffer->notification + i;
82 if (notif->clusterChange == SA_CLM_NODE_JOINED) {
89 ast_debug(1,
"A node has joined the cluster, dumping event cache.\n");
97 SaClmClusterNotificationBufferT buf;
98 SaClmClusterNotificationT notif[64];
103 e->
command =
"ais clm show members";
105 "Usage: ais clm show members\n"
106 " List members of the cluster using the CLM (Cluster Membership) service.\n";
116 buf.notification = notif;
119 ais_res = saClmClusterTrack(
clm_handle, SA_TRACK_CURRENT, &buf);
120 if (ais_res != SA_AIS_OK) {
121 ast_cli(a->
fd,
"Error retrieving current cluster members.\n");
126 "=============================================================\n"
127 "=== Cluster Members =========================================\n"
128 "=============================================================\n"
131 for (i = 0; i < buf.numberOfItems; i++) {
132 SaClmClusterNodeT *node = &buf.notification[i].clusterNode;
134 ast_cli(a->
fd,
"=== ---------------------------------------------------------\n"
135 "=== Node Name: %s\n"
137 "=== ==> Address: %s\n"
138 "=== ==> Member: %s\n",
139 (
char *) node->nodeName.value, (
int) node->nodeId,
140 (
char *) node->nodeAddress.value,
141 node->member ?
"Yes" :
"No");
143 ast_cli(a->
fd,
"=== ---------------------------------------------------------\n"
147 ast_cli(a->
fd,
"=============================================================\n"
168 ais_res = saClmClusterTrack(
clm_handle, SA_TRACK_CHANGES, NULL);
169 if (ais_res != SA_AIS_OK) {
170 ast_log(
LOG_ERROR,
"Error starting tracking of cluster membership changes.\n");
189 if (ais_res != SA_AIS_OK) {
static void clm_track_cb(const SaClmClusterNotificationBufferT *notif_buffer, SaUint32T num_members, SaAisErrorT error)
#define AST_CLI_DEFINE(fn, txt,...)
Asterisk main include file. File version handling, generic pbx functions.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
descriptor for a cli entry.
static const SaClmCallbacksT clm_callbacks
void ast_cli(int fd, const char *fmt,...)
int args
This gets set in ast_cli_register()
int ast_ais_clm_load_module(void)
#define ast_debug(level,...)
Log a DEBUG message.
static SaAisErrorT clm_init_res
Usage of the SAForum AIS (Application Interface Specification)
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
static void clm_node_get_cb(SaInvocationT invocation, const SaClmClusterNodeT *cluster_node, SaAisErrorT error)
Support for logging to various files, console and syslog Configuration in file logger.conf.
static char * ais_clm_show_members(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
Standard Command Line Interface.
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
const char * ais_err2str(SaAisErrorT error)
int ast_ais_clm_unload_module(void)
Asterisk module definitions.
static struct ast_cli_entry ais_cli[]
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.