summaryrefslogtreecommitdiffstats
path: root/daemons/controld/controld_alerts.c
blob: 27a5ce2758925d8b505a9dd41f9fda719fc0a603 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
 * Copyright 2012-2021 the Pacemaker project contributors
 *
 * The version control history for this file may have further details.
 *
 * This source code is licensed under the GNU General Public License version 2
 * or later (GPLv2+) WITHOUT ANY WARRANTY.
 */

#include <crm_internal.h>

#include <glib.h>
#include <libxml/tree.h>

#include <crm/fencing/internal.h>
#include <crm/lrmd.h>
#include <crm/lrmd_internal.h>
#include <crm/pengine/rules_internal.h>
#include <crm/pengine/status.h>
#include <crm/stonith-ng.h>

#include <pacemaker-controld.h>

static GList *crmd_alert_list = NULL;

void
crmd_unpack_alerts(xmlNode *alerts)
{
    pe_free_alert_list(crmd_alert_list);
    crmd_alert_list = pe_unpack_alerts(alerts);
}

void
crmd_alert_node_event(crm_node_t *node)
{
    lrm_state_t *lrm_state;

    if (crmd_alert_list == NULL) {
        return;
    }

    lrm_state = lrm_state_find(controld_globals.our_nodename);
    if (lrm_state == NULL) {
        return;
    }

    lrmd_send_node_alert((lrmd_t *) lrm_state->conn, crmd_alert_list,
                         node->uname, node->id, node->state);
}

void
crmd_alert_fencing_op(stonith_event_t * e)
{
    char *desc;
    lrm_state_t *lrm_state;

    if (crmd_alert_list == NULL) {
        return;
    }

    lrm_state = lrm_state_find(controld_globals.our_nodename);
    if (lrm_state == NULL) {
        return;
    }

    desc = stonith__event_description(e);
    lrmd_send_fencing_alert((lrmd_t *) lrm_state->conn, crmd_alert_list,
                            e->target, e->operation, desc, e->result);
    free(desc);
}

void
crmd_alert_resource_op(const char *node, lrmd_event_data_t * op)
{
    lrm_state_t *lrm_state;

    if (crmd_alert_list == NULL) {
        return;
    }

    lrm_state = lrm_state_find(controld_globals.our_nodename);
    if (lrm_state == NULL) {
        return;
    }

    lrmd_send_resource_alert((lrmd_t *) lrm_state->conn, crmd_alert_list, node,
                             op);
}