MCPcopy Create free account
hub / github.com/ClusterLabs/pacemaker / unpack_template

Function unpack_template

lib/pengine/complex.c:190–291  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188}
189
190static gboolean
191unpack_template(xmlNode * xml_obj, xmlNode ** expanded_xml, pe_working_set_t * data_set)
192{
193 xmlNode *cib_resources = NULL;
194 xmlNode *template = NULL;
195 xmlNode *new_xml = NULL;
196 xmlNode *child_xml = NULL;
197 xmlNode *rsc_ops = NULL;
198 xmlNode *template_ops = NULL;
199 const char *template_ref = NULL;
200 const char *id = NULL;
201
202 if (xml_obj == NULL) {
203 pe_err("No resource object for template unpacking");
204 return FALSE;
205 }
206
207 template_ref = crm_element_value(xml_obj, XML_CIB_TAG_RSC_TEMPLATE);
208 if (template_ref == NULL) {
209 return TRUE;
210 }
211
212 id = ID(xml_obj);
213 if (id == NULL) {
214 pe_err("'%s' object must have a id", crm_element_name(xml_obj));
215 return FALSE;
216 }
217
218 if (crm_str_eq(template_ref, id, TRUE)) {
219 pe_err("The resource object '%s' should not reference itself", id);
220 return FALSE;
221 }
222
223 cib_resources = get_object_root(XML_CIB_TAG_RESOURCES, data_set->input);
224 if (cib_resources == NULL) {
225 pe_err("Cannot get the root of object '%s'", XML_CIB_TAG_RESOURCES);
226 return FALSE;
227 }
228
229 template = find_entity(cib_resources, XML_CIB_TAG_RSC_TEMPLATE, template_ref);
230 if (template == NULL) {
231 pe_err("No template named '%s'", template_ref);
232 return FALSE;
233 }
234
235 new_xml = copy_xml(template);
236 xmlNodeSetName(new_xml, xml_obj->name);
237 crm_xml_replace(new_xml, XML_ATTR_ID, id);
238 template_ops = find_xml_node(new_xml, "operations", FALSE);
239
240 for (child_xml = __xml_first_child(xml_obj); child_xml != NULL;
241 child_xml = __xml_next(child_xml)) {
242 xmlNode *new_child = NULL;
243
244 new_child = add_node_copy(new_xml, child_xml);
245
246 if (crm_str_eq((const char *)new_child->name, "operations", TRUE)) {
247 rsc_ops = new_child;

Callers 1

common_unpackFunction · 0.85

Calls 12

crm_element_valueFunction · 0.85
crm_str_eqFunction · 0.85
get_object_rootFunction · 0.85
find_entityFunction · 0.85
copy_xmlFunction · 0.85
crm_xml_replaceFunction · 0.85
find_xml_nodeFunction · 0.85
__xml_first_childFunction · 0.85
__xml_nextFunction · 0.85
add_node_copyFunction · 0.85
template_op_keyFunction · 0.85
free_xmlFunction · 0.85

Tested by

no test coverage detected