17 #define VARIANT_CLONE 1
24 if (pe_rsc_is_clone(rsc)) {
25 clone_variant_data_t *clone_data = NULL;
27 get_clone_variant_data(clone_data, rsc);
30 "such as %s can be used only as anonymous clones",
31 rsc->
id, standard, rid);
33 clone_data->clone_node_max = 1;
34 clone_data->clone_max = QB_MIN(clone_data->clone_max,
35 g_list_length(data_set->
nodes));
42 char *child_id = NULL;
44 const char *child_base = NULL;
45 clone_variant_data_t *clone_data = NULL;
47 get_clone_variant_data(clone_data, rsc);
49 child_base =
ID(clone_data->xml_obj_child);
50 child_id = crm_concat(child_base, sub_id,
':');
60 gboolean as_orphan = FALSE;
64 xmlNode *child_copy = NULL;
65 clone_variant_data_t *clone_data = NULL;
67 get_clone_variant_data(clone_data, rsc);
69 CRM_CHECK(clone_data->xml_obj_child != NULL,
return FALSE);
71 if (clone_data->total_clones >= clone_data->clone_max) {
77 inc_num = crm_itoa(clone_data->total_clones);
78 inc_max = crm_itoa(clone_data->clone_max);
80 child_copy =
copy_xml(clone_data->xml_obj_child);
84 if (
common_unpack(child_copy, &child_rsc, rsc, data_set) == FALSE) {
92 clone_data->total_clones += 1;
93 pe_rsc_trace(child_rsc,
"Setting clone attributes for: %s", child_rsc->
id);
114 xmlNode *a_child = NULL;
115 xmlNode *xml_obj = rsc->
xml;
116 clone_variant_data_t *clone_data = NULL;
125 clone_data = calloc(1,
sizeof(clone_variant_data_t));
129 const char *promoted_max = NULL;
130 const char *promoted_node_max = NULL;
132 promoted_max = g_hash_table_lookup(rsc->
meta,
134 if (promoted_max == NULL) {
136 promoted_max = g_hash_table_lookup(rsc->
meta,
140 promoted_node_max = g_hash_table_lookup(rsc->
meta,
142 if (promoted_node_max == NULL) {
144 promoted_node_max = g_hash_table_lookup(rsc->
meta,
149 clone_data->promoted_node_max =
crm_parse_int(promoted_node_max,
"1");
155 clone_data->clone_node_max =
crm_parse_int(max_clones_node,
"1");
160 }
else if (g_list_length(data_set->
nodes) > 0) {
161 clone_data->clone_max = g_list_length(data_set->
nodes);
164 clone_data->clone_max = 1;
171 crm_config_err(
"Anonymous clones (%s) may only support one copy per node", rsc->
id);
172 clone_data->clone_node_max = 1;
176 pe_rsc_trace(rsc,
"\tClone max: %d", clone_data->clone_max);
177 pe_rsc_trace(rsc,
"\tClone node max: %d", clone_data->clone_node_max);
184 for (a_child = __xml_first_child(xml_obj); a_child != NULL;
185 a_child = __xml_next_element(a_child)) {
189 clone_data->xml_obj_child = a_child;
194 if (clone_data->xml_obj_child == NULL) {
215 if (clone_data->clone_max <= 0) {
225 for (lpc = 0; lpc < clone_data->clone_max; lpc++) {
232 pe_rsc_trace(rsc,
"Added %d children to resource %s...", clone_data->clone_max, rsc->
id);
241 for (; gIter != NULL; gIter = gIter->next) {
243 gboolean child_active = child_rsc->
fns->
active(child_rsc, all);
245 if (all == FALSE && child_active) {
247 }
else if (all && child_active == FALSE) {
260 short_print(
char *list,
const char *prefix,
const char *
type,
const char *suffix,
long options,
void *print_data)
287 const char *target_role = g_hash_table_lookup(rsc->
meta,
300 const char *target_role = configured_role_str(rsc);
309 clone_print_xml(
resource_t * rsc,
const char *pre_text,
long options,
void *print_data)
311 char *child_text = crm_concat(pre_text,
" ",
' ');
312 const char *target_role = configured_role_str(rsc);
328 for (; gIter != NULL; gIter = gIter->next) {
331 child_rsc->
fns->
print(child_rsc, child_text, options, print_data);
343 if(is_set(rsc->
flags, flag)) {
351 for (gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
371 char *list_text = NULL;
372 char *child_text = NULL;
373 char *stopped_list = NULL;
379 clone_variant_data_t *clone_data = NULL;
380 int active_instances = 0;
382 if (pre_text == NULL) {
387 clone_print_xml(rsc, pre_text, options, print_data);
391 get_clone_variant_data(clone_data, rsc);
393 child_text = crm_concat(pre_text,
" ",
' ');
396 pre_text ? pre_text :
"", rsc->
id,
ID(clone_data->xml_obj_child),
408 for (; gIter != NULL; gIter = gIter->next) {
409 gboolean print_full = FALSE;
411 gboolean partially_active = child_rsc->
fns->
active(child_rsc, FALSE);
431 }
else if (partially_active == FALSE) {
445 }
else if (child_rsc->
fns->
active(child_rsc, TRUE)) {
459 master_list = g_list_append(master_list, location);
462 started_list = g_list_append(started_list, location);
479 child_rsc->
fns->
print(child_rsc, child_text, options, print_data);
488 for (gIter = master_list; gIter; gIter = gIter->next) {
495 short_print(list_text, child_text,
"Masters", NULL, options, print_data);
496 g_list_free(master_list);
502 for (gIter = started_list; gIter; gIter = gIter->next) {
513 short_print(list_text, child_text,
"Slaves (target-role)", NULL, options, print_data);
515 short_print(list_text, child_text,
"Slaves", NULL, options, print_data);
519 short_print(list_text, child_text,
"Started", NULL, options, print_data);
522 g_list_free(started_list);
527 const char *state =
"Stopped";
531 state =
"Stopped (disabled)";
535 && (clone_data->clone_max > active_instances)) {
541 free(stopped_list); stopped_list = NULL;
543 if (g_list_length(list) == 0) {
547 list = g_hash_table_get_values(rsc->
known_on);
551 for (nIter = list; nIter != NULL; nIter = nIter->next) {
561 short_print(stopped_list, child_text, state, NULL, options, print_data);
575 clone_variant_data_t *clone_data = NULL;
577 get_clone_variant_data(clone_data, rsc);
587 child_rsc->
xml = NULL;
591 child_rsc->
fns->
free(child_rsc);
597 CRM_ASSERT(clone_data->demote_notify == NULL);
600 CRM_ASSERT(clone_data->promote_notify == NULL);
612 for (; gIter != NULL; gIter = gIter->next) {
616 if (a_role > clone_role) {
636 if (pe_rsc_is_clone(rsc)) {
637 clone_variant_data_t *clone_data = NULL;
639 get_clone_variant_data(clone_data, rsc);
640 if (clone_data->clone_max == g_list_length(data_set->
nodes)) {