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

Function unpack_domains

lib/pengine/unpack.c:300–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298}
299
300gboolean
301unpack_domains(xmlNode * xml_domains, pe_working_set_t * data_set)
302{
303 const char *id = NULL;
304 GListPtr domain = NULL;
305 xmlNode *xml_node = NULL;
306 xmlNode *xml_domain = NULL;
307
308 crm_info("Unpacking domains");
309 data_set->domains =
310 g_hash_table_new_full(crm_str_hash, g_str_equal, g_hash_destroy_str,
311 g_hash_destroy_node_list);
312
313 for (xml_domain = __xml_first_child(xml_domains); xml_domain != NULL;
314 xml_domain = __xml_next(xml_domain)) {
315 if (crm_str_eq((const char *)xml_domain->name, XML_CIB_TAG_DOMAIN, TRUE)) {
316 domain = NULL;
317 id = crm_element_value(xml_domain, XML_ATTR_ID);
318
319 for (xml_node = __xml_first_child(xml_domain); xml_node != NULL;
320 xml_node = __xml_next(xml_node)) {
321 if (crm_str_eq((const char *)xml_node->name, XML_CIB_TAG_NODE, TRUE)) {
322 node_t *copy = NULL;
323 node_t *node = NULL;
324 const char *uname = crm_element_value(xml_node, "name");
325 const char *score = crm_element_value(xml_node, XML_RULE_ATTR_SCORE);
326
327 if (uname == NULL) {
328 crm_config_err("Invalid domain %s: Must specify id tag in <node>", id);
329 continue;
330 }
331
332 node = pe_find_node(data_set->nodes, uname);
333 if (node == NULL) {
334 node = pe_find_node_id(data_set->nodes, uname);
335 }
336 if (node == NULL) {
337 crm_config_warn("Invalid domain %s: Node %s does not exist", id, uname);
338 continue;
339 }
340
341 copy = node_copy(node);
342 copy->weight = char2score(score);
343 crm_debug("Adding %s to domain %s with score %s", node->details->uname, id,
344 score);
345
346 domain = g_list_prepend(domain, copy);
347 }
348 }
349
350 if (domain) {
351 crm_debug("Created domain %s with %d members", id, g_list_length(domain));
352 g_hash_table_replace(data_set->domains, strdup(id), domain);
353 }
354 }
355 }
356
357 return TRUE;

Callers 1

cluster_statusFunction · 0.85

Calls 8

__xml_first_childFunction · 0.85
__xml_nextFunction · 0.85
crm_str_eqFunction · 0.85
crm_element_valueFunction · 0.85
pe_find_nodeFunction · 0.85
pe_find_node_idFunction · 0.85
node_copyFunction · 0.85
char2scoreFunction · 0.85

Tested by

no test coverage detected