create active recurring operations as optional */
| 1340 | |
| 1341 | /* create active recurring operations as optional */ |
| 1342 | static void |
| 1343 | process_recurring(node_t * node, resource_t * rsc, |
| 1344 | int start_index, int stop_index, |
| 1345 | GListPtr sorted_op_list, pe_working_set_t * data_set) |
| 1346 | { |
| 1347 | int counter = -1; |
| 1348 | const char *task = NULL; |
| 1349 | const char *status = NULL; |
| 1350 | GListPtr gIter = sorted_op_list; |
| 1351 | |
| 1352 | pe_rsc_trace(rsc, "%s: Start index %d, stop index = %d", rsc->id, start_index, stop_index); |
| 1353 | |
| 1354 | for (; gIter != NULL; gIter = gIter->next) { |
| 1355 | xmlNode *rsc_op = (xmlNode *) gIter->data; |
| 1356 | |
| 1357 | int interval = 0; |
| 1358 | char *key = NULL; |
| 1359 | const char *id = ID(rsc_op); |
| 1360 | const char *interval_s = NULL; |
| 1361 | |
| 1362 | counter++; |
| 1363 | |
| 1364 | if (node->details->online == FALSE) { |
| 1365 | pe_rsc_trace(rsc, "Skipping %s/%s: node is offline", rsc->id, node->details->uname); |
| 1366 | break; |
| 1367 | |
| 1368 | /* Need to check if there's a monitor for role="Stopped" */ |
| 1369 | } else if (start_index < stop_index && counter <= stop_index) { |
| 1370 | pe_rsc_trace(rsc, "Skipping %s/%s: resource is not active", id, node->details->uname); |
| 1371 | continue; |
| 1372 | |
| 1373 | } else if (counter < start_index) { |
| 1374 | pe_rsc_trace(rsc, "Skipping %s/%s: old %d", id, node->details->uname, counter); |
| 1375 | continue; |
| 1376 | } |
| 1377 | |
| 1378 | interval_s = crm_element_value(rsc_op, XML_LRM_ATTR_INTERVAL); |
| 1379 | interval = crm_parse_int(interval_s, "0"); |
| 1380 | if (interval == 0) { |
| 1381 | pe_rsc_trace(rsc, "Skipping %s/%s: non-recurring", id, node->details->uname); |
| 1382 | continue; |
| 1383 | } |
| 1384 | |
| 1385 | status = crm_element_value(rsc_op, XML_LRM_ATTR_OPSTATUS); |
| 1386 | if (safe_str_eq(status, "-1")) { |
| 1387 | pe_rsc_trace(rsc, "Skipping %s/%s: status", id, node->details->uname); |
| 1388 | continue; |
| 1389 | } |
| 1390 | task = crm_element_value(rsc_op, XML_LRM_ATTR_TASK); |
| 1391 | /* create the action */ |
| 1392 | key = generate_op_key(rsc->id, task, interval); |
| 1393 | pe_rsc_trace(rsc, "Creating %s/%s", key, node->details->uname); |
| 1394 | custom_action(rsc, key, task, node, TRUE, TRUE, data_set); |
| 1395 | } |
| 1396 | } |
| 1397 | |
| 1398 | void |
| 1399 | calculate_active_ops(GListPtr sorted_op_list, int *start_index, int *stop_index) |
no test coverage detected