18 #ifndef CRM_COMPATIBILITY__H
19 # define CRM_COMPATIBILITY__H
20 # define LOG_DEBUG_2 LOG_TRACE
21 # define LOG_DEBUG_3 LOG_TRACE
22 # define LOG_DEBUG_4 LOG_TRACE
23 # define LOG_DEBUG_5 LOG_TRACE
24 # define LOG_DEBUG_6 LOG_TRACE
26 # define XML_CIB_ATTR_HASTATE "ha"
27 # define XML_CIB_ATTR_JOINSTATE XML_NODE_JOIN_STATE
28 # define XML_CIB_ATTR_EXPSTATE XML_NODE_EXPECTED
29 # define XML_CIB_ATTR_INCCM XML_NODE_IN_CLUSTER
30 # define XML_CIB_ATTR_CRMDSTATE XML_NODE_IS_PEER
32 # define CRMD_STATE_ACTIVE CRMD_JOINSTATE_MEMBER
33 # define CRMD_STATE_INACTIVE CRMD_JOINSTATE_DOWN
35 #define pcmk_err_dtd_validation pcmk_err_schema_validation
120 # define stonith_error2string pcmk_strerror
121 # define lrmd_error2string pcmk_strerror
122 # define cib_error2string pcmk_strerror
129 for (gIter = list; gIter != NULL; gIter = gIter->next) {
135 # define crm_strdup strdup
136 # define set_bit_inplace set_bit
137 # define clear_bit_inplace clear_bit
139 # define crm_malloc0(malloc_obj, length) do { \
140 malloc_obj = malloc(length); \
141 if(malloc_obj == NULL) { \
142 crm_err("Failed allocation of %lu bytes", (unsigned long)length); \
143 CRM_ASSERT(malloc_obj != NULL); \
145 memset(malloc_obj, 0, length); \
148 # define crm_malloc(malloc_obj, length) do { \
149 malloc_obj = malloc(length); \
150 if(malloc_obj == NULL) { \
151 crm_err("Failed allocation of %lu bytes", (unsigned long)length); \
152 CRM_ASSERT(malloc_obj != NULL); \
156 # define crm_realloc(realloc_obj, length) do { \
157 realloc_obj = realloc(realloc_obj, length); \
158 CRM_ASSERT(realloc_obj != NULL); \
161 # define crm_free(free_obj) do { free(free_obj); free_obj=NULL; } while(0)
167 # define xml_child_iter(parent, child, code) do { \
168 if(parent != NULL) { \
169 xmlNode *child = NULL; \
170 xmlNode *__crm_xml_iter = parent->children; \
171 while(__crm_xml_iter != NULL) { \
172 child = __crm_xml_iter; \
173 __crm_xml_iter = __crm_xml_iter->next; \
174 if(child->type == XML_ELEMENT_NODE) { \
181 # define xml_child_iter_filter(parent, child, filter, code) do { \
182 if(parent != NULL) { \
183 xmlNode *child = NULL; \
184 xmlNode *__crm_xml_iter = parent->children; \
185 while(__crm_xml_iter != NULL) { \
186 child = __crm_xml_iter; \
187 __crm_xml_iter = __crm_xml_iter->next; \
188 if(child->type == XML_ELEMENT_NODE) { \
190 || crm_str_eq(filter, (const char *)child->name, TRUE)) { \
198 # define xml_prop_iter(parent, prop_name, prop_value, code) do { \
199 if(parent != NULL) { \
200 xmlAttrPtr prop_iter = parent->properties; \
201 const char *prop_name = NULL; \
202 const char *prop_value = NULL; \
203 while(prop_iter != NULL) { \
204 prop_name = (const char *)prop_iter->name; \
205 prop_value = crm_element_value(parent, prop_name); \
206 prop_iter = prop_iter->next; \
214 # define xml_prop_name_iter(parent, prop_name, code) do { \
215 if(parent != NULL) { \
216 xmlAttrPtr prop_iter = parent->properties; \
217 const char *prop_name = NULL; \
218 while(prop_iter != NULL) { \
219 prop_name = (const char *)prop_iter->name; \
220 prop_iter = prop_iter->next; \
228 # define zap_xml_from_parent(parent, xml_obj) free_xml(xml_obj); xml_obj = NULL
232 calculate_xml_digest(xmlNode * input, gboolean sort, gboolean do_filter)
234 return calculate_xml_digest_v1(input, sort, do_filter);
238 free_xml_from_parent(xmlNode * parent, xmlNode * a_node)
251 # define slist_destroy(child_type, child, parent, a) do { \
252 GListPtr __crm_iter_head = parent; \
253 child_type *child = NULL; \
254 while(__crm_iter_head != NULL) { \
255 child = (child_type *) __crm_iter_head->data; \
256 __crm_iter_head = __crm_iter_head->next; \
259 g_list_free(parent); \
263 static inline gboolean
264 attrd_update(
crm_ipc_t * cluster,
char command,
const char *
host,
const char *name,
265 const char *value,
const char *section,
const char *set,
const char *dampen)
271 static inline gboolean
272 attrd_lazy_update(
char command,
const char *
host,
const char *name,
273 const char *value,
const char *section,
const char *set,
const char *dampen)
278 static inline gboolean
279 attrd_update_no_mainloop(
int *connection,
char command,
const char *
host,
280 const char *name,
const char *value,
const char *section,
281 const char *set,
const char *dampen)
289 update_attr(
cib_t * the_cib,
int call_options,
290 const char *section,
const char *node_uuid,
const char *set_type,
const char *set_name,
291 const char *attr_id,
const char *attr_name,
const char *attr_value, gboolean to_console)
294 attr_id, attr_name, attr_value, to_console, NULL, NULL);
298 find_nvpair_attr(
cib_t * the_cib,
const char *attr,
const char *section,
const char *node_uuid,
299 const char *set_type,
const char *set_name,
const char *attr_id,
300 const char *attr_name, gboolean to_console,
char **value)
303 set_name, attr_id, attr_name, to_console, value, NULL);
307 read_attr(
cib_t * the_cib,
308 const char *section,
const char *node_uuid,
const char *set_type,
const char *set_name,
309 const char *attr_id,
const char *attr_name,
char **attr_value, gboolean to_console)
312 attr_id, attr_name, attr_value, to_console, NULL);
316 delete_attr(
cib_t * the_cib,
int options,
317 const char *section,
const char *node_uuid,
const char *set_type,
const char *set_name,
318 const char *attr_id,
const char *attr_name,
const char *attr_value, gboolean to_console)
321 attr_id, attr_name, attr_value, to_console, NULL);
325 log_cib_diff(
int log_level, xmlNode * diff,
const char *
function)
330 static inline gboolean
331 apply_cib_diff(xmlNode * old, xmlNode * diff, xmlNode **
new)
339 # ifdef CRM_COMMON_XML__H
341 log_xml_diff(
uint8_t log_level, xmlNode * diff,
const char *
function)
#define pcmk_err_old_data
xmlNode * copy_xml(xmlNode *src_node)
#define pcmk_err_diff_failed
int read_attr_delegate(cib_t *the_cib, const char *section, const char *node_uuid, const char *set_type, const char *set_name, const char *attr_id, const char *attr_name, char **attr_value, gboolean to_console, const char *user_name)
#define pcmk_err_diff_resync
int find_nvpair_attr_delegate(cib_t *the_cib, const char *attr, const char *section, const char *node_uuid, const char *set_type, const char *set_name, const char *attr_id, const char *attr_name, gboolean to_console, char **value, const char *user_name)
int xml_apply_patchset(xmlNode *xml, xmlNode *patchset, bool check_version)
struct crm_ipc_s crm_ipc_t
#define pcmk_err_no_quorum
#define pcmk_err_schema_validation
void free_xml(xmlNode *child)
#define pcmk_err_transform_failed
int attrd_update_delegate(crm_ipc_t *ipc, char command, const char *host, const char *name, const char *value, const char *section, const char *set, const char *dampen, const char *user_name, int options)
Send a request to attrd.
int delete_attr_delegate(cib_t *the_cib, int options, const char *section, const char *node_uuid, const char *set_type, const char *set_name, const char *attr_id, const char *attr_name, const char *attr_value, gboolean to_console, const char *user_name)
int update_attr_delegate(cib_t *the_cib, int call_options, const char *section, const char *node_uuid, const char *set_type, const char *set_name, const char *attr_id, const char *attr_name, const char *attr_value, gboolean to_console, const char *user_name, const char *node_type)
void xml_log_patchset(uint8_t level, const char *function, xmlNode *xml)