| 221 | } |
| 222 | |
| 223 | static int |
| 224 | node_list_attr_score(GHashTable * list, const char *attr, const char *value) |
| 225 | { |
| 226 | GHashTableIter iter; |
| 227 | node_t *node = NULL; |
| 228 | int best_score = -INFINITY; |
| 229 | const char *best_node = NULL; |
| 230 | |
| 231 | if (attr == NULL) { |
| 232 | attr = "#" XML_ATTR_UNAME; |
| 233 | } |
| 234 | |
| 235 | g_hash_table_iter_init(&iter, list); |
| 236 | while (g_hash_table_iter_next(&iter, NULL, (void **)&node)) { |
| 237 | int weight = node->weight; |
| 238 | |
| 239 | if (can_run_resources(node) == FALSE) { |
| 240 | weight = -INFINITY; |
| 241 | } |
| 242 | if (weight > best_score || best_node == NULL) { |
| 243 | const char *tmp = g_hash_table_lookup(node->details->attrs, attr); |
| 244 | |
| 245 | if (safe_str_eq(value, tmp)) { |
| 246 | best_score = weight; |
| 247 | best_node = node->details->uname; |
| 248 | } |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | if (safe_str_neq(attr, "#" XML_ATTR_UNAME)) { |
| 253 | crm_info("Best score for %s=%s was %s with %d", |
| 254 | attr, value, best_node ? best_node : "<none>", best_score); |
| 255 | } |
| 256 | |
| 257 | return best_score; |
| 258 | } |
| 259 | |
| 260 | static void |
| 261 | node_hash_update(GHashTable * list1, GHashTable * list2, const char *attr, float factor, |
no test coverage detected