| 1374 | } |
| 1375 | |
| 1376 | static gboolean |
| 1377 | unpack_order_template(xmlNode *xml_obj, xmlNode **expanded_xml, pe_working_set_t *data_set) |
| 1378 | { |
| 1379 | const char *id = NULL; |
| 1380 | const char *id_first = NULL; |
| 1381 | const char *id_then = NULL; |
| 1382 | const char *action_first = NULL; |
| 1383 | const char *action_then = NULL; |
| 1384 | |
| 1385 | resource_t *rsc_first = NULL; |
| 1386 | resource_t *rsc_then = NULL; |
| 1387 | |
| 1388 | xmlNode *new_xml = NULL; |
| 1389 | xmlNode *rsc_set_first = NULL; |
| 1390 | xmlNode *rsc_set_then = NULL; |
| 1391 | gboolean any_sets = FALSE; |
| 1392 | |
| 1393 | *expanded_xml = NULL; |
| 1394 | |
| 1395 | if(xml_obj == NULL) { |
| 1396 | crm_config_err("No constraint object to process."); |
| 1397 | return FALSE; |
| 1398 | } |
| 1399 | |
| 1400 | id = crm_element_value(xml_obj, XML_ATTR_ID); |
| 1401 | if(id == NULL) { |
| 1402 | crm_config_err("%s constraint must have an id", crm_element_name(xml_obj)); |
| 1403 | return FALSE; |
| 1404 | } |
| 1405 | |
| 1406 | /* Attempt to expand any template references in possible resource sets. */ |
| 1407 | expand_templates_in_sets(xml_obj, &new_xml, data_set); |
| 1408 | if (new_xml) { |
| 1409 | /* There are resource sets referencing templates. Return with the expanded XML. */ |
| 1410 | crm_log_xml_trace(new_xml, "Expanded rsc_order..."); |
| 1411 | *expanded_xml = new_xml; |
| 1412 | return TRUE; |
| 1413 | } |
| 1414 | |
| 1415 | id_first = crm_element_value(xml_obj, XML_ORDER_ATTR_FIRST); |
| 1416 | id_then = crm_element_value(xml_obj, XML_ORDER_ATTR_THEN); |
| 1417 | if(id_first == NULL || id_then == NULL) { |
| 1418 | return TRUE; |
| 1419 | } |
| 1420 | |
| 1421 | rsc_first = pe_find_resource(data_set->resources, id_first); |
| 1422 | rsc_then = pe_find_resource(data_set->resources, id_then); |
| 1423 | if(rsc_first && rsc_then) { |
| 1424 | /* Neither side references any template. */ |
| 1425 | return TRUE; |
| 1426 | } |
| 1427 | |
| 1428 | if (rsc_first == NULL) { |
| 1429 | xmlNode *template_rsc_set_first = NULL; |
| 1430 | gboolean rc = g_hash_table_lookup_extended(data_set->template_rsc_sets, id_first, |
| 1431 | NULL, (gpointer) &template_rsc_set_first); |
| 1432 | |
| 1433 | if (rc == FALSE) { |
no test coverage detected