pacemaker  2.0.4-2deceaa
Scalable High-Availability cluster resource manager
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cib_attrs.c
Go to the documentation of this file.
1 /*
2  * Copyright 2004-2020 the Pacemaker project contributors
3  *
4  * The version control history for this file may have further details.
5  *
6  * This source code is licensed under the GNU Lesser General Public License
7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8  */
9 
10 #include <crm_internal.h>
11 
12 #include <sys/param.h>
13 
14 #include <crm/crm.h>
15 
16 #include <stdio.h>
17 #include <sys/types.h>
18 #include <unistd.h>
19 
20 #include <stdlib.h>
21 #include <errno.h>
22 #include <fcntl.h>
23 #include <libgen.h>
24 
25 #include <crm/msg_xml.h>
26 #include <crm/common/xml.h>
27 #include <crm/cib/internal.h>
28 
29 #define attr_msg(level, fmt, args...) do { \
30  if(to_console) { \
31  printf(fmt"\n", ##args); \
32  } else { \
33  do_crm_log(level, fmt , ##args); \
34  } \
35  } while(0)
36 
37 /* could also check for possible truncation */
38 #define attr_snprintf(_str, _offset, _limit, ...) do { \
39  _offset += snprintf(_str + _offset, \
40  (_limit > _offset) ? _limit - _offset : 0, \
41  __VA_ARGS__); \
42  } while(0)
43 
44 #define XPATH_MAX 1024
45 
46 extern int
47 find_nvpair_attr_delegate(cib_t * the_cib, const char *attr, const char *section,
48  const char *node_uuid, const char *attr_set_type, const char *set_name,
49  const char *attr_id, const char *attr_name, gboolean to_console,
50  char **value, const char *user_name)
51 {
52  int offset = 0;
53  int rc = pcmk_ok;
54 
55  char *xpath_string = NULL;
56  xmlNode *xml_search = NULL;
57  const char *set_type = NULL;
58  const char *node_type = NULL;
59 
60  if (attr_set_type) {
61  set_type = attr_set_type;
62  } else {
63  set_type = XML_TAG_ATTR_SETS;
64  }
65 
66  CRM_ASSERT(value != NULL);
67  *value = NULL;
68 
69  if (safe_str_eq(section, XML_CIB_TAG_CRMCONFIG)) {
70  node_uuid = NULL;
71  set_type = XML_CIB_TAG_PROPSET;
72 
73  } else if (safe_str_eq(section, XML_CIB_TAG_OPCONFIG)
74  || safe_str_eq(section, XML_CIB_TAG_RSCCONFIG)) {
75  node_uuid = NULL;
76  set_type = XML_TAG_META_SETS;
77 
78  } else if (safe_str_eq(section, XML_CIB_TAG_TICKETS)) {
79  node_uuid = NULL;
80  section = XML_CIB_TAG_STATUS;
81  node_type = XML_CIB_TAG_TICKETS;
82 
83  } else if (node_uuid == NULL) {
84  return -EINVAL;
85  }
86 
87  xpath_string = calloc(1, XPATH_MAX);
88  if (xpath_string == NULL) {
89  crm_perror(LOG_CRIT, "Could not create xpath");
90  return -ENOMEM;
91  }
92 
93  attr_snprintf(xpath_string, offset, XPATH_MAX, "%.128s", get_object_path(section));
94 
95  if (safe_str_eq(node_type, XML_CIB_TAG_TICKETS)) {
96  attr_snprintf(xpath_string, offset, XPATH_MAX, "//%s", node_type);
97 
98  } else if (node_uuid) {
99  const char *node_type = XML_CIB_TAG_NODE;
100 
101  if (safe_str_eq(section, XML_CIB_TAG_STATUS)) {
102  node_type = XML_CIB_TAG_STATE;
103  set_type = XML_TAG_TRANSIENT_NODEATTRS;
104  }
105  attr_snprintf(xpath_string, offset, XPATH_MAX, "//%s[@id='%s']", node_type,
106  node_uuid);
107  }
108 
109  if (set_name) {
110  attr_snprintf(xpath_string, offset, XPATH_MAX, "//%s[@id='%.128s']", set_type,
111  set_name);
112  } else {
113  attr_snprintf(xpath_string, offset, XPATH_MAX, "//%s", set_type);
114  }
115 
116  attr_snprintf(xpath_string, offset, XPATH_MAX, "//nvpair[");
117  if (attr_id) {
118  attr_snprintf(xpath_string, offset, XPATH_MAX, "@id='%s'", attr_id);
119  }
120 
121  if (attr_name) {
122  if (attr_id) {
123  attr_snprintf(xpath_string, offset, XPATH_MAX, " and ");
124  }
125  attr_snprintf(xpath_string, offset, XPATH_MAX, "@name='%.128s'", attr_name);
126  }
127  attr_snprintf(xpath_string, offset, XPATH_MAX, "]");
128  CRM_LOG_ASSERT(offset > 0);
129 
130  rc = cib_internal_op(the_cib, CIB_OP_QUERY, NULL, xpath_string, NULL, &xml_search,
131  cib_sync_call | cib_scope_local | cib_xpath, user_name);
132 
133  if (rc != pcmk_ok) {
134  crm_trace("Query failed for attribute %s (section=%s, node=%s, set=%s, xpath=%s): %s",
135  attr_name, section, crm_str(node_uuid), crm_str(set_name), xpath_string,
136  pcmk_strerror(rc));
137  goto done;
138  }
139 
140  crm_log_xml_debug(xml_search, "Match");
141  if (xml_has_children(xml_search)) {
142  xmlNode *child = NULL;
143 
144  rc = -ENOTUNIQ;
145  attr_msg(LOG_WARNING, "Multiple attributes match name=%s", attr_name);
146 
147  for (child = __xml_first_child(xml_search); child != NULL; child = __xml_next(child)) {
148  attr_msg(LOG_INFO, " Value: %s \t(id=%s)",
149  crm_element_value(child, XML_NVPAIR_ATTR_VALUE), ID(child));
150  }
151 
152  } else {
153  const char *tmp = crm_element_value(xml_search, attr);
154 
155  if (tmp) {
156  *value = strdup(tmp);
157  }
158  }
159 
160  done:
161  free(xpath_string);
162  free_xml(xml_search);
163  return rc;
164 }
165 
166 int
167 update_attr_delegate(cib_t * the_cib, int call_options,
168  const char *section, const char *node_uuid, const char *set_type,
169  const char *set_name, const char *attr_id, const char *attr_name,
170  const char *attr_value, gboolean to_console, const char *user_name,
171  const char *node_type)
172 {
173  const char *tag = NULL;
174  int rc = pcmk_ok;
175  xmlNode *xml_top = NULL;
176  xmlNode *xml_obj = NULL;
177 
178  char *local_attr_id = NULL;
179  char *local_set_name = NULL;
180 
181  CRM_CHECK(section != NULL, return -EINVAL);
182  CRM_CHECK(attr_value != NULL, return -EINVAL);
183  CRM_CHECK(attr_name != NULL || attr_id != NULL, return -EINVAL);
184 
185  rc = find_nvpair_attr_delegate(the_cib, XML_ATTR_ID, section, node_uuid, set_type, set_name,
186  attr_id, attr_name, to_console, &local_attr_id, user_name);
187  if (rc == pcmk_ok) {
188  attr_id = local_attr_id;
189  goto do_modify;
190 
191  } else if (rc != -ENXIO) {
192  return rc;
193 
194  /* } else if(attr_id == NULL) { */
195  /* return -EINVAL; */
196 
197  } else {
198  crm_trace("%s does not exist, create it", attr_name);
199  if (safe_str_eq(section, XML_CIB_TAG_TICKETS)) {
200  node_uuid = NULL;
201  section = XML_CIB_TAG_STATUS;
202  node_type = XML_CIB_TAG_TICKETS;
203 
204  xml_top = create_xml_node(xml_obj, XML_CIB_TAG_STATUS);
205  xml_obj = create_xml_node(xml_top, XML_CIB_TAG_TICKETS);
206 
207  } else if (safe_str_eq(section, XML_CIB_TAG_NODES)) {
208 
209  if (node_uuid == NULL) {
210  return -EINVAL;
211  }
212 
213  if (safe_str_eq(node_type, "remote")) {
214  xml_top = create_xml_node(xml_obj, XML_CIB_TAG_NODES);
215  xml_obj = create_xml_node(xml_top, XML_CIB_TAG_NODE);
216  crm_xml_add(xml_obj, XML_ATTR_TYPE, "remote");
217  crm_xml_add(xml_obj, XML_ATTR_ID, node_uuid);
218  crm_xml_add(xml_obj, XML_ATTR_UNAME, node_uuid);
219  } else {
220  tag = XML_CIB_TAG_NODE;
221  }
222 
223  } else if (safe_str_eq(section, XML_CIB_TAG_STATUS)) {
225  if (node_uuid == NULL) {
226  return -EINVAL;
227  }
228 
229  xml_top = create_xml_node(xml_obj, XML_CIB_TAG_STATE);
230  crm_xml_add(xml_top, XML_ATTR_ID, node_uuid);
231  xml_obj = xml_top;
232 
233  } else {
234  tag = section;
235  node_uuid = NULL;
236  }
237 
238  if (set_name == NULL) {
239  if (safe_str_eq(section, XML_CIB_TAG_CRMCONFIG)) {
240  local_set_name = strdup(CIB_OPTIONS_FIRST);
241 
242  } else if (safe_str_eq(node_type, XML_CIB_TAG_TICKETS)) {
243  local_set_name = crm_strdup_printf("%s-%s", section,
245 
246  } else if (node_uuid) {
247  local_set_name = crm_strdup_printf("%s-%s", section, node_uuid);
248 
249  if (set_type) {
250  char *tmp_set_name = local_set_name;
251 
252  local_set_name = crm_strdup_printf("%s-%s", tmp_set_name,
253  set_type);
254  free(tmp_set_name);
255  }
256  } else {
257  local_set_name = crm_strdup_printf("%s-options", section);
258  }
259  set_name = local_set_name;
260  }
261 
262  if (attr_id == NULL) {
263  local_attr_id = crm_strdup_printf("%s-%s", set_name, attr_name);
264  crm_xml_sanitize_id(local_attr_id);
265  attr_id = local_attr_id;
266 
267  } else if (attr_name == NULL) {
268  attr_name = attr_id;
269  }
270 
271  crm_trace("Creating %s/%s", section, tag);
272  if (tag != NULL) {
273  xml_obj = create_xml_node(xml_obj, tag);
274  crm_xml_add(xml_obj, XML_ATTR_ID, node_uuid);
275  if (xml_top == NULL) {
276  xml_top = xml_obj;
277  }
278  }
279 
280  if (node_uuid == NULL && safe_str_neq(node_type, XML_CIB_TAG_TICKETS)) {
281  if (safe_str_eq(section, XML_CIB_TAG_CRMCONFIG)) {
282  xml_obj = create_xml_node(xml_obj, XML_CIB_TAG_PROPSET);
283  } else {
284  xml_obj = create_xml_node(xml_obj, XML_TAG_META_SETS);
285  }
286 
287  } else if (set_type) {
288  xml_obj = create_xml_node(xml_obj, set_type);
289 
290  } else {
291  xml_obj = create_xml_node(xml_obj, XML_TAG_ATTR_SETS);
292  }
293  crm_xml_add(xml_obj, XML_ATTR_ID, set_name);
294 
295  if (xml_top == NULL) {
296  xml_top = xml_obj;
297  }
298  }
299 
300  do_modify:
301  xml_obj = crm_create_nvpair_xml(xml_obj, attr_id, attr_name, attr_value);
302  if (xml_top == NULL) {
303  xml_top = xml_obj;
304  }
305 
306  crm_log_xml_trace(xml_top, "update_attr");
307  rc = cib_internal_op(the_cib, CIB_OP_MODIFY, NULL, section, xml_top, NULL,
308  call_options | cib_quorum_override, user_name);
309 
310  if (rc < pcmk_ok) {
311  attr_msg(LOG_ERR, "Error setting %s=%s (section=%s, set=%s): %s",
312  attr_name, attr_value, section, crm_str(set_name), pcmk_strerror(rc));
313  crm_log_xml_info(xml_top, "Update");
314  }
315 
316  free(local_set_name);
317  free(local_attr_id);
318  free_xml(xml_top);
319 
320  return rc;
321 }
322 
323 int
325  const char *section, const char *node_uuid, const char *set_type,
326  const char *set_name, const char *attr_id, const char *attr_name,
327  char **attr_value, gboolean to_console, const char *user_name)
328 {
329  int rc = pcmk_ok;
330 
331  CRM_ASSERT(attr_value != NULL);
332  CRM_CHECK(section != NULL, return -EINVAL);
333  CRM_CHECK(attr_name != NULL || attr_id != NULL, return -EINVAL);
334 
335  *attr_value = NULL;
336 
337  rc = find_nvpair_attr_delegate(the_cib, XML_NVPAIR_ATTR_VALUE, section, node_uuid, set_type,
338  set_name, attr_id, attr_name, to_console, attr_value, user_name);
339  if (rc != pcmk_ok) {
340  crm_trace("Query failed for attribute %s (section=%s, node=%s, set=%s): %s",
341  attr_name, section, crm_str(set_name), crm_str(node_uuid), pcmk_strerror(rc));
342  }
343  return rc;
344 }
345 
346 int
347 delete_attr_delegate(cib_t * the_cib, int options,
348  const char *section, const char *node_uuid, const char *set_type,
349  const char *set_name, const char *attr_id, const char *attr_name,
350  const char *attr_value, gboolean to_console, const char *user_name)
351 {
352  int rc = pcmk_ok;
353  xmlNode *xml_obj = NULL;
354  char *local_attr_id = NULL;
355 
356  CRM_CHECK(section != NULL, return -EINVAL);
357  CRM_CHECK(attr_name != NULL || attr_id != NULL, return -EINVAL);
358 
359  if (attr_id == NULL) {
360  rc = find_nvpair_attr_delegate(the_cib, XML_ATTR_ID, section, node_uuid, set_type,
361  set_name, attr_id, attr_name, to_console, &local_attr_id,
362  user_name);
363  if (rc != pcmk_ok) {
364  return rc;
365  }
366  attr_id = local_attr_id;
367  }
368 
369  xml_obj = crm_create_nvpair_xml(NULL, attr_id, attr_name, attr_value);
370 
371  rc = cib_internal_op(the_cib, CIB_OP_DELETE, NULL, section, xml_obj, NULL,
372  options | cib_quorum_override, user_name);
373 
374  if (rc == pcmk_ok) {
375  attr_msg(LOG_DEBUG, "Deleted %s %s: id=%s%s%s%s%s\n",
376  section, node_uuid ? "attribute" : "option", local_attr_id,
377  set_name ? " set=" : "", set_name ? set_name : "",
378  attr_name ? " name=" : "", attr_name ? attr_name : "");
379  }
380 
381  free(local_attr_id);
382  free_xml(xml_obj);
383  return rc;
384 }
385 
396 static int
397 get_uuid_from_result(xmlNode *result, char **uuid, int *is_remote)
398 {
399  int rc = -ENXIO;
400  const char *tag;
401  const char *parsed_uuid = NULL;
402  int parsed_is_remote = FALSE;
403 
404  if (result == NULL) {
405  return rc;
406  }
407 
408  /* If there are multiple results, the first is sufficient */
409  tag = (const char *) (result->name);
410  if (safe_str_eq(tag, "xpath-query")) {
411  result = __xml_first_child(result);
412  CRM_CHECK(result != NULL, return rc);
413  tag = (const char *) (result->name);
414  }
415 
416  if (safe_str_eq(tag, XML_CIB_TAG_NODE)) {
417  /* Result is <node> tag from <nodes> section */
418 
419  if (safe_str_eq(crm_element_value(result, XML_ATTR_TYPE), "remote")) {
420  parsed_uuid = crm_element_value(result, XML_ATTR_UNAME);
421  parsed_is_remote = TRUE;
422  } else {
423  parsed_uuid = ID(result);
424  parsed_is_remote = FALSE;
425  }
426 
427  } else if (safe_str_eq(tag, XML_CIB_TAG_RESOURCE)) {
428  /* Result is <primitive> for ocf:pacemaker:remote resource */
429 
430  parsed_uuid = ID(result);
431  parsed_is_remote = TRUE;
432 
433  } else if (safe_str_eq(tag, XML_CIB_TAG_NVPAIR)) {
434  /* Result is remote-node parameter of <primitive> for guest node */
435 
436  parsed_uuid = crm_element_value(result, XML_NVPAIR_ATTR_VALUE);
437  parsed_is_remote = TRUE;
438 
439  } else if (safe_str_eq(tag, XML_CIB_TAG_STATE)) {
440  /* Result is <node_state> tag from <status> section */
441 
442  parsed_uuid = crm_element_value(result, XML_ATTR_UNAME);
444  parsed_is_remote = TRUE;
445  }
446  }
447 
448  if (parsed_uuid) {
449  if (uuid) {
450  *uuid = strdup(parsed_uuid);
451  }
452  if (is_remote) {
453  *is_remote = parsed_is_remote;
454  }
455  rc = pcmk_ok;
456  }
457 
458  return rc;
459 }
460 
461 /* Search string to find a node by name, as:
462  * - cluster or remote node in nodes section
463  * - remote node in resources section
464  * - guest node in resources section
465  * - orphaned remote node or bundle guest node in status section
466  */
467 #define XPATH_UPPER_TRANS "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
468 #define XPATH_LOWER_TRANS "abcdefghijklmnopqrstuvwxyz"
469 #define XPATH_NODE \
470  "/" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION "/" XML_CIB_TAG_NODES \
471  "/" XML_CIB_TAG_NODE "[translate(@" XML_ATTR_UNAME ",'" XPATH_UPPER_TRANS "','" XPATH_LOWER_TRANS "') ='%s']" \
472  "|/" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION "/" XML_CIB_TAG_RESOURCES \
473  "/" XML_CIB_TAG_RESOURCE \
474  "[@class='ocf'][@provider='pacemaker'][@type='remote'][translate(@id,'" XPATH_UPPER_TRANS "','" XPATH_LOWER_TRANS "') ='%s']" \
475  "|/" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION "/" XML_CIB_TAG_RESOURCES \
476  "/" XML_CIB_TAG_RESOURCE "/" XML_TAG_META_SETS "/" XML_CIB_TAG_NVPAIR \
477  "[@name='" XML_RSC_ATTR_REMOTE_NODE "'][translate(@value,'" XPATH_UPPER_TRANS "','" XPATH_LOWER_TRANS "') ='%s']" \
478  "|/" XML_TAG_CIB "/" XML_CIB_TAG_STATUS "/" XML_CIB_TAG_STATE \
479  "[@" XML_NODE_IS_REMOTE "='true'][translate(@" XML_ATTR_UUID ",'" XPATH_UPPER_TRANS "','" XPATH_LOWER_TRANS "') ='%s']"
480 
481 int
482 query_node_uuid(cib_t * the_cib, const char *uname, char **uuid, int *is_remote_node)
483 {
484  int rc = pcmk_ok;
485  char *xpath_string;
486  xmlNode *xml_search = NULL;
487  char *host_lowercase = g_ascii_strdown(uname, -1);
488 
489  CRM_ASSERT(uname != NULL);
490 
491  if (uuid) {
492  *uuid = NULL;
493  }
494  if (is_remote_node) {
495  *is_remote_node = FALSE;
496  }
497 
498  xpath_string = crm_strdup_printf(XPATH_NODE, host_lowercase, host_lowercase, host_lowercase, host_lowercase);
499  if (cib_internal_op(the_cib, CIB_OP_QUERY, NULL, xpath_string, NULL,
501  NULL) == pcmk_ok) {
502  rc = get_uuid_from_result(xml_search, uuid, is_remote_node);
503  } else {
504  rc = -ENXIO;
505  }
506  free(xpath_string);
507  free_xml(xml_search);
508  g_free(host_lowercase);
509 
510  if (rc != pcmk_ok) {
511  crm_debug("Could not map node name '%s' to a UUID: %s",
512  uname, pcmk_strerror(rc));
513  } else {
514  crm_info("Mapped node name '%s' to UUID %s", uname, (uuid? *uuid : ""));
515  }
516  return rc;
517 }
518 
519 int
520 query_node_uname(cib_t * the_cib, const char *uuid, char **uname)
521 {
522  int rc = pcmk_ok;
523  xmlNode *a_child = NULL;
524  xmlNode *xml_obj = NULL;
525  xmlNode *fragment = NULL;
526  const char *child_name = NULL;
527 
528  CRM_ASSERT(uname != NULL);
529  CRM_ASSERT(uuid != NULL);
530 
531  rc = the_cib->cmds->query(the_cib, XML_CIB_TAG_NODES, &fragment,
533  if (rc != pcmk_ok) {
534  return rc;
535  }
536 
537  xml_obj = fragment;
538  CRM_CHECK(safe_str_eq(crm_element_name(xml_obj), XML_CIB_TAG_NODES), return -ENOMSG);
539  CRM_ASSERT(xml_obj != NULL);
540  crm_log_xml_trace(xml_obj, "Result section");
541 
542  rc = -ENXIO;
543  *uname = NULL;
544 
545  for (a_child = __xml_first_child(xml_obj); a_child != NULL; a_child = __xml_next(a_child)) {
546  if (crm_str_eq((const char *)a_child->name, XML_CIB_TAG_NODE, TRUE)) {
547  child_name = ID(a_child);
548  if (safe_str_eq(uuid, child_name)) {
549  child_name = crm_element_value(a_child, XML_ATTR_UNAME);
550  if (child_name != NULL) {
551  *uname = strdup(child_name);
552  rc = pcmk_ok;
553  }
554  break;
555  }
556  }
557  }
558 
559  free_xml(fragment);
560  return rc;
561 }
562 
563 int
564 set_standby(cib_t * the_cib, const char *uuid, const char *scope, const char *standby_value)
565 {
566  int rc = pcmk_ok;
567  char *attr_id = NULL;
568 
569  CRM_CHECK(uuid != NULL, return -EINVAL);
570  CRM_CHECK(standby_value != NULL, return -EINVAL);
571 
572  if (safe_str_eq(scope, "reboot") || safe_str_eq(scope, XML_CIB_TAG_STATUS)) {
573  scope = XML_CIB_TAG_STATUS;
574  attr_id = crm_strdup_printf("transient-standby-%.256s", uuid);
575 
576  } else {
577  scope = XML_CIB_TAG_NODES;
578  attr_id = crm_strdup_printf("standby-%.256s", uuid);
579  }
580 
581  rc = update_attr_delegate(the_cib, cib_sync_call, scope, uuid, NULL, NULL,
582  attr_id, "standby", standby_value, TRUE, NULL, NULL);
583 
584  free(attr_id);
585  return rc;
586 }
int(* query)(cib_t *cib, const char *section, xmlNode **output_data, int call_options)
Definition: cib_types.h:92
#define CRM_CHECK(expr, failure_action)
Definition: logging.h:233
char uname[MAX_NAME]
Definition: internal.h:85
A dumping ground.
const char * pcmk_strerror(int rc)
Definition: results.c:55
gboolean safe_str_neq(const char *a, const char *b)
Definition: strings.c:263
#define XML_ATTR_TYPE
Definition: msg_xml.h:99
#define XML_TAG_TRANSIENT_NODEATTRS
Definition: msg_xml.h:365
const char * get_object_path(const char *object_type)
Definition: cib_utils.c:115
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
Definition: nvpair.c:316
int query_node_uuid(cib_t *the_cib, const char *uname, char **uuid, int *is_remote_node)
Definition: cib_attrs.c:482
int set_standby(cib_t *the_cib, const char *uuid, const char *scope, const char *standby_value)
Definition: cib_attrs.c:564
#define CRM_LOG_ASSERT(expr)
Definition: logging.h:219
#define attr_snprintf(_str, _offset, _limit,...)
Definition: cib_attrs.c:38
#define XML_CIB_TAG_NVPAIR
Definition: msg_xml.h:160
#define XML_CIB_TAG_NODES
Definition: msg_xml.h:141
void crm_xml_sanitize_id(char *id)
Sanitize a string so it is usable as an XML ID.
Definition: xml.c:2440
#define XML_CIB_TAG_PROPSET
Definition: msg_xml.h:162
#define XML_TAG_ATTR_SETS
Definition: msg_xml.h:163
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)
Definition: cib_attrs.c:324
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)
Definition: cib_attrs.c:47
int rc
Definition: pcmk_fence.c:34
cib_api_operations_t * cmds
Definition: cib_types.h:147
#define crm_debug(fmt, args...)
Definition: logging.h:368
#define XML_ATTR_ID
Definition: msg_xml.h:96
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
Definition: nvpair.c:522
#define XML_CIB_TAG_RESOURCE
Definition: msg_xml.h:174
#define XML_CIB_TAG_STATE
Definition: msg_xml.h:158
#define CIB_OP_QUERY
Definition: internal.h:22
int query_node_uname(cib_t *the_cib, const char *uuid, char **uname)
Definition: cib_attrs.c:520
#define crm_trace(fmt, args...)
Definition: logging.h:369
#define crm_log_xml_debug(xml, text)
Definition: logging.h:376
#define XML_TAG_META_SETS
Definition: msg_xml.h:164
Wrappers for and extensions to libxml2.
#define XML_ATTR_UNAME
Definition: msg_xml.h:118
xmlNode * create_xml_node(xmlNode *parent, const char *name)
Definition: xml.c:1976
#define XML_NODE_IS_REMOTE
Definition: msg_xml.h:242
#define CIB_OPTIONS_FIRST
Definition: msg_xml.h:49
void free_xml(xmlNode *child)
Definition: xml.c:2136
#define XPATH_NODE
Definition: cib_attrs.c:469
gboolean xml_has_children(const xmlNode *root)
Definition: xml.c:3331
gboolean crm_str_eq(const char *a, const char *b, gboolean use_case)
Definition: strings.c:326
#define XML_CIB_TAG_NODE
Definition: msg_xml.h:159
#define XPATH_MAX
Definition: cib_attrs.c:44
#define crm_perror(level, fmt, args...)
Send a system error message to both the log and stderr.
Definition: logging.h:314
#define CRM_ASSERT(expr)
Definition: results.h:42
#define ENOTUNIQ
Definition: portability.h:134
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)
Definition: cib_attrs.c:347
node_type
Definition: pe_types.h:67
#define XML_CIB_TAG_CRMCONFIG
Definition: msg_xml.h:144
#define XML_CIB_TAG_RSCCONFIG
Definition: msg_xml.h:146
#define CIB_OP_DELETE
Definition: internal.h:25
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)
Definition: cib_attrs.c:167
#define crm_log_xml_info(xml, text)
Definition: logging.h:375
#define CIB_OP_MODIFY
Definition: internal.h:24
#define XML_NVPAIR_ATTR_VALUE
Definition: msg_xml.h:340
#define crm_str(x)
Definition: logging.h:389
#define attr_msg(level, fmt, args...)
Definition: cib_attrs.c:29
#define pcmk_ok
Definition: results.h:67
#define XML_CIB_TAG_STATUS
Definition: msg_xml.h:139
#define crm_log_xml_trace(xml, text)
Definition: logging.h:377
gboolean crm_is_true(const char *s)
Definition: strings.c:278
xmlNode * crm_create_nvpair_xml(xmlNode *parent, const char *id, const char *name, const char *value)
Create an XML name/value pair.
Definition: nvpair.c:847
#define ID(x)
Definition: msg_xml.h:418
int cib_internal_op(cib_t *cib, const char *op, const char *host, const char *section, xmlNode *data, xmlNode **output_data, int call_options, const char *user_name)
Definition: cib_utils.c:746
#define safe_str_eq(a, b)
Definition: util.h:65
#define XML_CIB_TAG_OPCONFIG
Definition: msg_xml.h:145
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
#define XML_CIB_TAG_TICKETS
Definition: msg_xml.h:388
#define crm_info(fmt, args...)
Definition: logging.h:366