| 2216 | } |
| 2217 | |
| 2218 | static GListPtr |
| 2219 | extract_operations(const char *node, const char *rsc, xmlNode * rsc_entry, gboolean active_filter) |
| 2220 | { |
| 2221 | int counter = -1; |
| 2222 | int stop_index = -1; |
| 2223 | int start_index = -1; |
| 2224 | |
| 2225 | xmlNode *rsc_op = NULL; |
| 2226 | |
| 2227 | GListPtr gIter = NULL; |
| 2228 | GListPtr op_list = NULL; |
| 2229 | GListPtr sorted_op_list = NULL; |
| 2230 | |
| 2231 | /* extract operations */ |
| 2232 | op_list = NULL; |
| 2233 | sorted_op_list = NULL; |
| 2234 | |
| 2235 | for (rsc_op = __xml_first_child(rsc_entry); rsc_op != NULL; rsc_op = __xml_next(rsc_op)) { |
| 2236 | if (crm_str_eq((const char *)rsc_op->name, XML_LRM_TAG_RSC_OP, TRUE)) { |
| 2237 | crm_xml_add(rsc_op, "resource", rsc); |
| 2238 | crm_xml_add(rsc_op, XML_ATTR_UNAME, node); |
| 2239 | op_list = g_list_prepend(op_list, rsc_op); |
| 2240 | } |
| 2241 | } |
| 2242 | |
| 2243 | if (op_list == NULL) { |
| 2244 | /* if there are no operations, there is nothing to do */ |
| 2245 | return NULL; |
| 2246 | } |
| 2247 | |
| 2248 | sorted_op_list = g_list_sort(op_list, sort_op_by_callid); |
| 2249 | |
| 2250 | /* create active recurring operations as optional */ |
| 2251 | if (active_filter == FALSE) { |
| 2252 | return sorted_op_list; |
| 2253 | } |
| 2254 | |
| 2255 | op_list = NULL; |
| 2256 | |
| 2257 | calculate_active_ops(sorted_op_list, &start_index, &stop_index); |
| 2258 | |
| 2259 | for (gIter = sorted_op_list; gIter != NULL; gIter = gIter->next) { |
| 2260 | xmlNode *rsc_op = (xmlNode *) gIter->data; |
| 2261 | |
| 2262 | counter++; |
| 2263 | |
| 2264 | if (start_index < stop_index) { |
| 2265 | crm_trace("Skipping %s: not active", ID(rsc_entry)); |
| 2266 | break; |
| 2267 | |
| 2268 | } else if (counter < start_index) { |
| 2269 | crm_trace("Skipping %s: old", ID(rsc_op)); |
| 2270 | continue; |
| 2271 | } |
| 2272 | op_list = g_list_append(op_list, rsc_op); |
| 2273 | } |
| 2274 | |
| 2275 | g_list_free(sorted_op_list); |
no test coverage detected