| 1021 | } |
| 1022 | |
| 1023 | static void |
| 1024 | show_colocation(resource_t * rsc, gboolean dependants, gboolean recursive, int offset) |
| 1025 | { |
| 1026 | char *prefix = NULL; |
| 1027 | GListPtr lpc = NULL; |
| 1028 | GListPtr list = rsc->rsc_cons; |
| 1029 | |
| 1030 | prefix = calloc(1, (offset * 4) + 1); |
| 1031 | memset(prefix, ' ', offset * 4); |
| 1032 | |
| 1033 | if (dependants) { |
| 1034 | list = rsc->rsc_cons_lhs; |
| 1035 | } |
| 1036 | |
| 1037 | if (is_set(rsc->flags, pe_rsc_allocating)) { |
| 1038 | /* Break colocation loops */ |
| 1039 | printf("loop %s\n", rsc->id); |
| 1040 | free(prefix); |
| 1041 | return; |
| 1042 | } |
| 1043 | |
| 1044 | set_bit(rsc->flags, pe_rsc_allocating); |
| 1045 | for (lpc = list; lpc != NULL; lpc = lpc->next) { |
| 1046 | rsc_colocation_t *cons = (rsc_colocation_t *) lpc->data; |
| 1047 | |
| 1048 | char *score = NULL; |
| 1049 | resource_t *peer = cons->rsc_rh; |
| 1050 | |
| 1051 | if (dependants) { |
| 1052 | peer = cons->rsc_lh; |
| 1053 | } |
| 1054 | |
| 1055 | if (is_set(peer->flags, pe_rsc_allocating)) { |
| 1056 | if (dependants == FALSE) { |
| 1057 | fprintf(stdout, "%s%-*s (id=%s - loop)\n", prefix, 80 - (4 * offset), peer->id, |
| 1058 | cons->id); |
| 1059 | } |
| 1060 | continue; |
| 1061 | } |
| 1062 | |
| 1063 | if (dependants && recursive) { |
| 1064 | show_colocation(peer, dependants, recursive, offset + 1); |
| 1065 | } |
| 1066 | |
| 1067 | score = score2char(cons->score); |
| 1068 | if (cons->role_rh > RSC_ROLE_STARTED) { |
| 1069 | fprintf(stdout, "%s%-*s (score=%s, %s role=%s, id=%s)\n", prefix, 80 - (4 * offset), |
| 1070 | peer->id, score, dependants ? "needs" : "with", role2text(cons->role_rh), |
| 1071 | cons->id); |
| 1072 | } else { |
| 1073 | fprintf(stdout, "%s%-*s (score=%s, id=%s)\n", prefix, 80 - (4 * offset), |
| 1074 | peer->id, score, cons->id); |
| 1075 | } |
| 1076 | show_location(peer, prefix); |
| 1077 | free(score); |
| 1078 | |
| 1079 | if (!dependants && recursive) { |
| 1080 | show_colocation(peer, dependants, recursive, offset + 1); |
no test coverage detected