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_internal.h>
18 #include <crm/common/messages_internal.h>
19 #include <crm/cib/internal.h>
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 #define ATTRD_PROTOCOL_VERSION "4"
46
47 #define attrd_send_ack(client, id, flags) \
48 pcmk__ipc_send_ack((client), (id), (flags), "ack", ATTRD_PROTOCOL_VERSION, CRM_EX_INDETERMINATE)
49
50 void attrd_init_mainloop(void);
51 void attrd_run_mainloop(void);
52
53 void attrd_set_requesting_shutdown(void);
54 void attrd_clear_requesting_shutdown(void);
55 bool attrd_requesting_shutdown(void);
56 bool attrd_shutting_down(void);
57 void attrd_shutdown(int nsig);
58 void attrd_init_ipc(void);
59 void attrd_ipc_fini(void);
60
61 void attrd_cib_disconnect(void);
62
63 bool attrd_value_needs_expansion(const char *value);
64 int attrd_expand_value(const char *value, const char *old_value);
65
66
67 #define ATTRD_RE_CLEAR_ALL \
68 "^(" PCMK__FAIL_COUNT_PREFIX "|" PCMK__LAST_FAILURE_PREFIX ")-"
69
70
71
72
73
74
75
76 #define ATTRD_RE_CLEAR_ONE ATTRD_RE_CLEAR_ALL "%s(#.+_[0-9]+)?$"
77
78
79
80
81
82
83
84 #define ATTRD_RE_CLEAR_OP ATTRD_RE_CLEAR_ALL "%s(#%s_%u)?$"
85
86 int attrd_failure_regex(regex_t *regex, const char *rsc, const char *op,
87 guint interval_ms);
88
89 extern cib_t *the_cib;
90
91
92
93 extern lrmd_t *the_lrmd;
94 extern crm_trigger_t *attrd_config_read;
95
96 void attrd_lrmd_disconnect(void);
97 gboolean attrd_read_options(gpointer user_data);
98 void attrd_cib_replaced_cb(const char *event, xmlNode * msg);
99 void attrd_cib_updated_cb(const char *event, xmlNode *msg);
100 int attrd_send_attribute_alert(const char *node, int nodeid,
101 const char *attr, const char *value);
102
103
104 void attrd_election_init(void);
105 void attrd_election_fini(void);
106 void attrd_start_election_if_needed(void);
107 bool attrd_election_won(void);
108 void attrd_handle_election_op(const crm_node_t *peer, xmlNode *xml);
109 bool attrd_check_for_new_writer(const crm_node_t *peer, const xmlNode *xml);
110 void attrd_declare_winner(void);
111 void attrd_remove_voter(const crm_node_t *peer);
112 void attrd_xml_add_writer(xmlNode *xml);
113
114 typedef struct attribute_s {
115 char *uuid;
116 char *id;
117 char *set;
118 GHashTable *values;
119 int update;
120 int timeout_ms;
121
122
123 bool changed;
124 bool unknown_peer_uuids;
125 gboolean is_private;
126
127 mainloop_timer_t *timer;
128
129 char *user;
130
131 gboolean force_write;
132
133 } attribute_t;
134
135 typedef struct attribute_value_s {
136 uint32_t nodeid;
137 gboolean is_remote;
138 char *nodename;
139 char *current;
140 char *requested;
141 gboolean seen;
142 } attribute_value_t;
143
144 extern crm_cluster_t *attrd_cluster;
145 extern GHashTable *attributes;
146
147 #define CIB_OP_TIMEOUT_S 120
148
149 int attrd_cluster_connect(void);
150 void attrd_peer_update(const crm_node_t *peer, xmlNode *xml, const char *host,
151 bool filter);
152 void attrd_peer_sync(crm_node_t *peer, xmlNode *xml);
153 void attrd_peer_remove(const char *host, bool uncache, const char *source);
154 void attrd_peer_clear_failure(pcmk__request_t *request);
155 void attrd_peer_sync_response(const crm_node_t *peer, bool peer_won,
156 xmlNode *xml);
157
158 void attrd_broadcast_protocol(void);
159 xmlNode *attrd_client_peer_remove(pcmk__request_t *request);
160 xmlNode *attrd_client_clear_failure(pcmk__request_t *request);
161 xmlNode *attrd_client_update(pcmk__request_t *request);
162 xmlNode *attrd_client_refresh(pcmk__request_t *request);
163 xmlNode *attrd_client_query(pcmk__request_t *request);
164 gboolean attrd_send_message(crm_node_t * node, xmlNode * data);
165
166 xmlNode *attrd_add_value_xml(xmlNode *parent, const attribute_t *a,
167 const attribute_value_t *v, bool force_write);
168 void attrd_clear_value_seen(void);
169 void attrd_free_attribute(gpointer data);
170 void attrd_free_attribute_value(gpointer data);
171 attribute_t *attrd_populate_attribute(xmlNode *xml, const char *attr);
172
173 void attrd_write_attribute(attribute_t *a, bool ignore_delay);
174 void attrd_write_attributes(bool all, bool ignore_delay);
175 void attrd_write_or_elect_attribute(attribute_t *a);
176
177 extern int minimum_protocol_version;
178 void attrd_update_minimum_protocol_ver(const char *value);
179
180 mainloop_timer_t *attrd_add_timer(const char *id, int timeout_ms, attribute_t *attr);
181
182 void attrd_unregister_handlers(void);
183 void attrd_handle_request(pcmk__request_t *request);
184
185 #endif