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

Function unpack_nodes

lib/pengine/unpack.c:193–290  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191}
192
193gboolean
194unpack_nodes(xmlNode * xml_nodes, pe_working_set_t * data_set)
195{
196 xmlNode *xml_obj = NULL;
197 node_t *new_node = NULL;
198 const char *id = NULL;
199 const char *uname = NULL;
200 const char *type = NULL;
201 const char *score = NULL;
202 gboolean unseen_are_unclean = TRUE;
203 const char *blind_faith = pe_pref(data_set->config_hash, "startup-fencing");
204
205 if (crm_is_true(blind_faith) == FALSE) {
206 unseen_are_unclean = FALSE;
207 crm_warn("Blind faith: not fencing unseen nodes");
208 }
209
210 for (xml_obj = __xml_first_child(xml_nodes); xml_obj != NULL; xml_obj = __xml_next(xml_obj)) {
211 if (crm_str_eq((const char *)xml_obj->name, XML_CIB_TAG_NODE, TRUE)) {
212 new_node = NULL;
213
214 id = crm_element_value(xml_obj, XML_ATTR_ID);
215 uname = crm_element_value(xml_obj, XML_ATTR_UNAME);
216 type = crm_element_value(xml_obj, XML_ATTR_TYPE);
217 score = crm_element_value(xml_obj, XML_RULE_ATTR_SCORE);
218 crm_trace("Processing node %s/%s", uname, id);
219
220 if (id == NULL) {
221 crm_config_err("Must specify id tag in <node>");
222 continue;
223 }
224 if (pe_find_node(data_set->nodes, uname) != NULL) {
225 crm_config_warn("Detected multiple node entries with uname=%s"
226 " - this is rarely intended", uname);
227 }
228
229 new_node = calloc(1, sizeof(node_t));
230 if (new_node == NULL) {
231 return FALSE;
232 }
233
234 new_node->weight = char2score(score);
235 new_node->fixed = FALSE;
236 new_node->details = calloc(1, sizeof(struct node_shared_s));
237
238 if (new_node->details == NULL) {
239 free(new_node);
240 return FALSE;
241 }
242
243 crm_trace("Creaing node for entry %s/%s", uname, id);
244 new_node->details->id = id;
245 new_node->details->uname = uname;
246 new_node->details->type = node_ping;
247 new_node->details->online = FALSE;
248 new_node->details->shutdown = FALSE;
249 new_node->details->running_rsc = NULL;
250 new_node->details->attrs = g_hash_table_new_full(crm_str_hash, g_str_equal,

Callers 1

cluster_statusFunction · 0.85

Calls 11

pe_prefFunction · 0.85
crm_is_trueFunction · 0.85
__xml_first_childFunction · 0.85
__xml_nextFunction · 0.85
crm_str_eqFunction · 0.85
crm_element_valueFunction · 0.85
pe_find_nodeFunction · 0.85
char2scoreFunction · 0.85
is_setFunction · 0.85
add_node_attrsFunction · 0.85

Tested by

no test coverage detected