| 334 | } |
| 335 | |
| 336 | gboolean |
| 337 | common_unpack(xmlNode * xml_obj, resource_t ** rsc, |
| 338 | resource_t * parent, pe_working_set_t * data_set) |
| 339 | { |
| 340 | xmlNode *expanded_xml = NULL; |
| 341 | xmlNode *ops = NULL; |
| 342 | resource_t *top = NULL; |
| 343 | const char *value = NULL; |
| 344 | const char *id = crm_element_value(xml_obj, XML_ATTR_ID); |
| 345 | const char *class = crm_element_value(xml_obj, XML_AGENT_ATTR_CLASS); |
| 346 | |
| 347 | crm_log_xml_trace(xml_obj, "Processing resource input..."); |
| 348 | |
| 349 | if (id == NULL) { |
| 350 | pe_err("Must specify id tag in <resource>"); |
| 351 | return FALSE; |
| 352 | |
| 353 | } else if (rsc == NULL) { |
| 354 | pe_err("Nowhere to unpack resource into"); |
| 355 | return FALSE; |
| 356 | |
| 357 | } |
| 358 | |
| 359 | if (unpack_template(xml_obj, &expanded_xml, data_set) == FALSE) { |
| 360 | return FALSE; |
| 361 | } |
| 362 | |
| 363 | *rsc = calloc(1, sizeof(resource_t)); |
| 364 | |
| 365 | if (expanded_xml) { |
| 366 | crm_log_xml_trace(expanded_xml, "Expanded resource..."); |
| 367 | (*rsc)->xml = expanded_xml; |
| 368 | (*rsc)->orig_xml = xml_obj; |
| 369 | |
| 370 | } else { |
| 371 | (*rsc)->xml = xml_obj; |
| 372 | (*rsc)->orig_xml = NULL; |
| 373 | } |
| 374 | |
| 375 | (*rsc)->parent = parent; |
| 376 | |
| 377 | ops = find_xml_node((*rsc)->xml, "operations", FALSE); |
| 378 | (*rsc)->ops_xml = expand_idref(ops, data_set->input); |
| 379 | |
| 380 | (*rsc)->variant = get_resource_type(crm_element_name(xml_obj)); |
| 381 | if ((*rsc)->variant == pe_unknown) { |
| 382 | pe_err("Unknown resource type: %s", crm_element_name(xml_obj)); |
| 383 | free(*rsc); |
| 384 | return FALSE; |
| 385 | } |
| 386 | |
| 387 | (*rsc)->parameters = |
| 388 | g_hash_table_new_full(crm_str_hash, g_str_equal, g_hash_destroy_str, g_hash_destroy_str); |
| 389 | |
| 390 | (*rsc)->meta = |
| 391 | g_hash_table_new_full(crm_str_hash, g_str_equal, g_hash_destroy_str, g_hash_destroy_str); |
| 392 | |
| 393 | (*rsc)->allowed_nodes = |
no test coverage detected