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

Function unpack_rsc_location

pengine/constraints.c:365–439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

363}
364
365gboolean
366unpack_rsc_location(xmlNode * xml_obj, pe_working_set_t * data_set)
367{
368 gboolean empty = TRUE;
369 rsc_to_node_t *location = NULL;
370 const char *id_lh = crm_element_value(xml_obj, "rsc");
371 const char *id = crm_element_value(xml_obj, XML_ATTR_ID);
372 resource_t *rsc_lh = pe_find_resource(data_set->resources, id_lh);
373 const char *node = crm_element_value(xml_obj, "node");
374 const char *score = crm_element_value(xml_obj, XML_RULE_ATTR_SCORE);
375 const char *domain = crm_element_value(xml_obj, XML_CIB_TAG_DOMAIN);
376 const char *role = crm_element_value(xml_obj, XML_RULE_ATTR_ROLE);
377
378 if (rsc_lh == NULL) {
379 /* only a warn as BSC adds the constraint then the resource */
380 crm_config_warn("No resource (con=%s, rsc=%s)", id, id_lh);
381 return FALSE;
382 }
383
384 if (domain) {
385 GListPtr nodes = g_hash_table_lookup(data_set->domains, domain);
386
387 if (domain == NULL) {
388 crm_config_err("Invalid constraint %s: Domain %s does not exist", id, domain);
389 return FALSE;
390 }
391
392 location = rsc2node_new(id, rsc_lh, 0, NULL, data_set);
393 location->node_list_rh = node_list_dup(nodes, FALSE, FALSE);
394
395 } else if (node != NULL && score != NULL) {
396 int score_i = char2score(score);
397 node_t *match = pe_find_node(data_set->nodes, node);
398
399 if (!match) {
400 return FALSE;
401 }
402 location = rsc2node_new(id, rsc_lh, score_i, match, data_set);
403
404 } else {
405 xmlNode *rule_xml = NULL;
406
407 for (rule_xml = __xml_first_child(xml_obj); rule_xml != NULL;
408 rule_xml = __xml_next(rule_xml)) {
409 if (crm_str_eq((const char *)rule_xml->name, XML_TAG_RULE, TRUE)) {
410 empty = FALSE;
411 crm_trace("Unpacking %s/%s", id, ID(rule_xml));
412 generate_location_rule(rsc_lh, rule_xml, data_set);
413 }
414 }
415
416 if (empty) {
417 crm_config_err("Invalid location constraint %s:"
418 " rsc_location must contain at least one rule", ID(xml_obj));
419 }
420 }
421
422 if (location && role) {

Callers 1

unpack_constraintsFunction · 0.85

Calls 11

crm_element_valueFunction · 0.85
pe_find_resourceFunction · 0.85
rsc2node_newFunction · 0.85
node_list_dupFunction · 0.85
char2scoreFunction · 0.85
pe_find_nodeFunction · 0.85
__xml_first_childFunction · 0.85
__xml_nextFunction · 0.85
crm_str_eqFunction · 0.85
generate_location_ruleFunction · 0.85
text2roleFunction · 0.85

Tested by

no test coverage detected