This source file includes following definitions.
- pcmk_cib_xpath_for
- pcmk_cib_parent_name_for
- pcmk_find_cib_element
1
2
3
4
5
6
7
8
9
10
11 #include <crm_internal.h>
12
13 #include <stdio.h>
14 #include <libxml/tree.h>
15
16 #include <crm/msg_xml.h>
17
18
19
20
21
22
23 static struct {
24 const char *name;
25 const char *parent;
26 const char *path;
27 } cib_sections[] = {
28 {
29
30 XML_TAG_CIB,
31 NULL,
32 "//" XML_TAG_CIB
33 },
34 {
35 XML_CIB_TAG_STATUS,
36 "/" XML_TAG_CIB,
37 "//" XML_TAG_CIB "/" XML_CIB_TAG_STATUS
38 },
39 {
40 XML_CIB_TAG_CONFIGURATION,
41 "/" XML_TAG_CIB,
42 "//" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION
43 },
44 {
45 XML_CIB_TAG_CRMCONFIG,
46 "/" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION,
47 "//" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION "/" XML_CIB_TAG_CRMCONFIG
48 },
49 {
50 XML_CIB_TAG_NODES,
51 "/" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION,
52 "//" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION "/" XML_CIB_TAG_NODES
53 },
54 {
55 XML_CIB_TAG_RESOURCES,
56 "/" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION,
57 "//" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION "/" XML_CIB_TAG_RESOURCES
58 },
59 {
60 XML_CIB_TAG_CONSTRAINTS,
61 "/" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION,
62 "//" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION "/" XML_CIB_TAG_CONSTRAINTS
63 },
64 {
65 XML_CIB_TAG_OPCONFIG,
66 "/" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION,
67 "//" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION "/" XML_CIB_TAG_OPCONFIG
68 },
69 {
70 XML_CIB_TAG_RSCCONFIG,
71 "/" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION,
72 "//" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION "/" XML_CIB_TAG_RSCCONFIG
73 },
74 {
75 XML_CIB_TAG_ACLS,
76 "/" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION,
77 "//" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION "/" XML_CIB_TAG_ACLS
78 },
79 {
80 XML_TAG_FENCING_TOPOLOGY,
81 "/" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION,
82 "//" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION "/" XML_TAG_FENCING_TOPOLOGY
83 },
84 {
85 XML_CIB_TAG_TAGS,
86 "/" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION,
87 "//" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION "/" XML_CIB_TAG_TAGS
88 },
89 {
90 XML_CIB_TAG_ALERTS,
91 "/" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION,
92 "//" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION "/" XML_CIB_TAG_ALERTS
93 },
94 {
95 XML_CIB_TAG_SECTION_ALL,
96 NULL,
97 "//" XML_TAG_CIB
98 },
99 };
100
101
102
103
104
105
106
107
108
109 const char *
110 pcmk_cib_xpath_for(const char *element_name)
111 {
112 for (int lpc = 0; lpc < PCMK__NELEM(cib_sections); lpc++) {
113
114 if (pcmk__str_eq(element_name, cib_sections[lpc].name,
115 pcmk__str_null_matches)) {
116 return cib_sections[lpc].path;
117 }
118 }
119 return NULL;
120 }
121
122
123
124
125
126
127
128
129
130 const char *
131 pcmk_cib_parent_name_for(const char *element_name)
132 {
133 for (int lpc = 0; lpc < PCMK__NELEM(cib_sections); lpc++) {
134
135 if (pcmk__str_eq(element_name, cib_sections[lpc].name,
136 pcmk__str_null_matches)) {
137 return cib_sections[lpc].parent;
138 }
139 }
140 return NULL;
141 }
142
143
144
145
146
147
148
149
150
151
152 xmlNode *
153 pcmk_find_cib_element(xmlNode *cib, const char *element_name)
154 {
155 return get_xpath_object(pcmk_cib_xpath_for(element_name), cib, LOG_TRACE);
156 }