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

Function show_colocation

tools/crm_resource.c:1023–1084  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1021}
1022
1023static void
1024show_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);

Callers 1

mainFunction · 0.85

Calls 4

is_setFunction · 0.85
score2charFunction · 0.85
role2textFunction · 0.85
show_locationFunction · 0.85

Tested by

no test coverage detected