1
2
3
4
5
6
7
8
9
10 #ifndef PACEMAKER_ATTRD__H
11 # define PACEMAKER_ATTRD__H
12
13 #include <regex.h>
14 #include <glib.h>
15 #include <crm/crm.h>
16 #include <crm/cluster.h>
17 #include <crm/cluster/election.h>
18 #include <crm/cib/internal.h>
19
20 void attrd_init_mainloop(void);
21 void attrd_run_mainloop(void);
22
23 gboolean attrd_shutting_down(void);
24 void attrd_shutdown(int nsig);
25 void attrd_init_ipc(qb_ipcs_service_t **ipcs,
26 qb_ipcs_msg_process_fn dispatch_fn);
27 void attrd_ipc_fini(void);
28
29 void attrd_cib_disconnect(void);
30
31 gboolean attrd_value_needs_expansion(const char *value);
32 int attrd_expand_value(const char *value, const char *old_value);
33
34
35 #define ATTRD_RE_CLEAR_ALL \
36 "^(" PCMK__FAIL_COUNT_PREFIX "|" PCMK__LAST_FAILURE_PREFIX ")-"
37
38
39
40
41
42
43
44 #define ATTRD_RE_CLEAR_ONE ATTRD_RE_CLEAR_ALL "%s(#.+_[0-9]+)?$"
45
46
47
48
49
50
51
52 #define ATTRD_RE_CLEAR_OP ATTRD_RE_CLEAR_ALL "%s(#%s_%u)?$"
53
54 int attrd_failure_regex(regex_t *regex, const char *rsc, const char *op,
55 guint interval_ms);
56
57 extern cib_t *the_cib;
58
59
60
61 extern lrmd_t *the_lrmd;
62 extern crm_trigger_t *attrd_config_read;
63
64 void attrd_lrmd_disconnect(void);
65 gboolean attrd_read_options(gpointer user_data);
66 void attrd_cib_replaced_cb(const char *event, xmlNode * msg);
67 void attrd_cib_updated_cb(const char *event, xmlNode *msg);
68 int attrd_send_attribute_alert(const char *node, int nodeid,
69 const char *attr, const char *value);
70
71
72 void attrd_election_init(void);
73 void attrd_election_fini(void);
74 void attrd_start_election_if_needed(void);
75 bool attrd_election_won(void);
76 void attrd_handle_election_op(const crm_node_t *peer, xmlNode *xml);
77 bool attrd_check_for_new_writer(const crm_node_t *peer, const xmlNode *xml);
78 void attrd_declare_winner(void);
79 void attrd_remove_voter(const crm_node_t *peer);
80 void attrd_xml_add_writer(xmlNode *xml);
81
82 typedef struct attribute_s {
83 char *uuid;
84 char *id;
85 char *set;
86 GHashTable *values;
87 int update;
88 int timeout_ms;
89
90
91 bool changed;
92 bool unknown_peer_uuids;
93 gboolean is_private;
94
95 mainloop_timer_t *timer;
96
97 char *user;
98
99 gboolean force_write;
100
101 } attribute_t;
102
103 typedef struct attribute_value_s {
104 uint32_t nodeid;
105 gboolean is_remote;
106 char *nodename;
107 char *current;
108 char *requested;
109 gboolean seen;
110 } attribute_value_t;
111
112 extern crm_cluster_t *attrd_cluster;
113 extern GHashTable *attributes;
114
115 #define attrd_send_ack(client, id, flags) \
116 pcmk__ipc_send_ack((client), (id), (flags), "ack", CRM_EX_INDETERMINATE)
117
118 #define CIB_OP_TIMEOUT_S 120
119
120 void write_attributes(bool all, bool ignore_delay);
121 void attrd_broadcast_protocol(void);
122 void attrd_peer_message(crm_node_t *client, xmlNode *msg);
123 void attrd_client_peer_remove(const char *client_name, xmlNode *xml);
124 void attrd_client_clear_failure(xmlNode *xml);
125 void attrd_client_update(xmlNode *xml);
126 void attrd_client_refresh(void);
127 void attrd_client_query(pcmk__client_t *client, uint32_t id, uint32_t flags,
128 xmlNode *query);
129
130 void free_attribute(gpointer data);
131
132 gboolean attrd_election_cb(gpointer user_data);
133 void attrd_peer_change_cb(enum crm_status_type type, crm_node_t *peer, const void *data);
134
135 #endif