18 #define VARIANT_CLONE 1
25 if (pe_rsc_is_clone(rsc)) {
26 clone_variant_data_t *clone_data = NULL;
28 get_clone_variant_data(clone_data, rsc);
31 "such as %s can be used only as anonymous clones",
32 rsc->
id, standard, rid);
34 clone_data->clone_node_max = 1;
35 clone_data->clone_max = QB_MIN(clone_data->clone_max,
36 g_list_length(data_set->
nodes));
43 char *child_id = NULL;
45 const char *child_base = NULL;
46 clone_variant_data_t *clone_data = NULL;
48 get_clone_variant_data(clone_data, rsc);
50 child_base =
ID(clone_data->xml_obj_child);
61 gboolean as_orphan = FALSE;
65 xmlNode *child_copy = NULL;
66 clone_variant_data_t *clone_data = NULL;
68 get_clone_variant_data(clone_data, rsc);
70 CRM_CHECK(clone_data->xml_obj_child != NULL,
return FALSE);
72 if (clone_data->total_clones >= clone_data->clone_max) {
78 inc_num = crm_itoa(clone_data->total_clones);
79 inc_max = crm_itoa(clone_data->clone_max);
81 child_copy =
copy_xml(clone_data->xml_obj_child);
85 if (
common_unpack(child_copy, &child_rsc, rsc, data_set) == FALSE) {
93 clone_data->total_clones += 1;
94 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;
124 clone_data = calloc(1,
sizeof(clone_variant_data_t));
128 const char *promoted_max = NULL;
129 const char *promoted_node_max = NULL;
131 promoted_max = g_hash_table_lookup(rsc->
meta,
133 if (promoted_max == NULL) {
135 promoted_max = g_hash_table_lookup(rsc->
meta,
139 promoted_node_max = g_hash_table_lookup(rsc->
meta,
141 if (promoted_node_max == NULL) {
143 promoted_node_max = g_hash_table_lookup(rsc->
meta,
148 clone_data->promoted_node_max =
crm_parse_int(promoted_node_max,
"1");
154 clone_data->clone_node_max =
crm_parse_int(max_clones_node,
"1");
159 }
else if (pcmk__list_of_multiple(data_set->
nodes)) {
160 clone_data->clone_max = g_list_length(data_set->
nodes);
163 clone_data->clone_max = 1;
170 "because anonymous clones support only one instance "
171 "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_element(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)
270 status_print(
"%s%s: [%s ]%s", prefix, type, list, suffix);
272 if (options & pe_print_html) {
287 const char *target_role = g_hash_table_lookup(rsc->
meta,
300 const char *target_role = configured_role_str(rsc);
309 clone_print_xml(
pe_resource_t * rsc,
const char *pre_text,
long options,
void *print_data)
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);
396 pre_text ? pre_text :
"", rsc->
id,
ID(clone_data->xml_obj_child),
401 if (options & pe_print_html) {
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);
476 if (options & pe_print_html) {
479 child_rsc->
fns->
print(child_rsc, child_text, options, print_data);
480 if (options & pe_print_html) {
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;
547 list = g_hash_table_get_values(rsc->
known_on);
551 for (nIter = list; nIter != NULL; nIter = nIter->next) {
562 short_print(stopped_list, child_text, state, NULL, options, print_data);
566 if (options & pe_print_html) {
577 unsigned int options = va_arg(args,
unsigned int);
584 gboolean printed_header = FALSE;
586 for (; gIter != NULL; gIter = gIter->next) {
593 if (!printed_header) {
594 printed_header = TRUE;
603 ,
"target_role", configured_role_str(rsc));
607 out->message(out, crm_map_element_name(child_rsc->
xml), options, child_rsc, only_show);
610 if (printed_header) {
621 unsigned int options = va_arg(args,
unsigned int);
625 char *list_text = NULL;
626 char *stopped_list = NULL;
632 clone_variant_data_t *clone_data = NULL;
633 int active_instances = 0;
635 get_clone_variant_data(clone_data, rsc);
637 out->begin_list(out, NULL, NULL,
"Clone Set: %s [%s]%s%s%s",
638 rsc->
id,
ID(clone_data->xml_obj_child),
643 for (; gIter != NULL; gIter = gIter->next) {
644 gboolean print_full = FALSE;
646 gboolean partially_active = child_rsc->
fns->
active(child_rsc, FALSE);
670 }
else if (partially_active == FALSE) {
684 }
else if (child_rsc->
fns->
active(child_rsc, TRUE)) {
698 master_list = g_list_append(master_list, location);
701 started_list = g_list_append(started_list, location);
715 out->message(out, crm_map_element_name(child_rsc->
xml), options, child_rsc, only_show);
727 for (gIter = master_list; gIter; gIter = gIter->next) {
738 if (list_text != NULL) {
739 out->list_item(out, NULL,
" Masters: [%s ]", list_text);
740 g_list_free(master_list);
747 for (gIter = started_list; gIter; gIter = gIter->next) {
758 if (list_text != NULL) {
763 out->list_item(out, NULL,
" Slaves (target-role): [%s ]", list_text);
765 out->list_item(out, NULL,
" Slaves: [%s ]", list_text);
769 out->list_item(out, NULL,
" Started: [%s ]", list_text);
772 g_list_free(started_list);
778 const char *state =
"Stopped";
782 state =
"Stopped (disabled)";
786 && (clone_data->clone_max > active_instances)) {
799 list = g_hash_table_get_values(rsc->
known_on);
803 for (nIter = list; nIter != NULL; nIter = nIter->next) {
815 if (stopped_list != NULL) {
816 out->list_item(out, NULL,
" %s: [%s ]", state, stopped_list);
830 unsigned int options = va_arg(args,
unsigned int);
834 char *list_text = NULL;
835 char *stopped_list = NULL;
841 clone_variant_data_t *clone_data = NULL;
842 int active_instances = 0;
844 get_clone_variant_data(clone_data, rsc);
846 out->begin_list(out, NULL, NULL,
"Clone Set: %s [%s]%s%s%s",
847 rsc->
id,
ID(clone_data->xml_obj_child),
852 for (; gIter != NULL; gIter = gIter->next) {
853 gboolean print_full = FALSE;
855 gboolean partially_active = child_rsc->
fns->
active(child_rsc, FALSE);
879 }
else if (partially_active == FALSE) {
893 }
else if (child_rsc->
fns->
active(child_rsc, TRUE)) {
907 master_list = g_list_append(master_list, location);
910 started_list = g_list_append(started_list, location);
924 out->message(out, crm_map_element_name(child_rsc->
xml), options, child_rsc, only_show);
936 for (gIter = master_list; gIter; gIter = gIter->next) {
947 if (list_text != NULL) {
948 out->list_item(out,
"Masters",
"[%s ]", list_text);
949 g_list_free(master_list);
956 for (gIter = started_list; gIter; gIter = gIter->next) {
967 if (list_text != NULL) {
972 out->list_item(out,
"Slaves (target-role)",
"[%s ]", list_text);
974 out->list_item(out,
"Slaves",
"[%s ]", list_text);
977 out->list_item(out,
"Started",
"[%s ]", list_text);
980 g_list_free(started_list);
986 const char *state =
"Stopped";
990 state =
"Stopped (disabled)";
994 && (clone_data->clone_max > active_instances)) {
1001 stopped_list = NULL;
1007 list = g_hash_table_get_values(rsc->
known_on);
1011 for (nIter = list; nIter != NULL; nIter = nIter->next) {
1023 if (stopped_list != NULL) {
1024 out->list_item(out, state,
"[%s ]", stopped_list);
1037 clone_variant_data_t *clone_data = NULL;
1039 get_clone_variant_data(clone_data, rsc);
1049 child_rsc->
xml = NULL;
1053 child_rsc->
fns->
free(child_rsc);
1059 CRM_ASSERT(clone_data->demote_notify == NULL);
1061 CRM_ASSERT(clone_data->start_notify == NULL);
1062 CRM_ASSERT(clone_data->promote_notify == NULL);
1074 for (; gIter != NULL; gIter = gIter->next) {
1078 if (a_role > clone_role) {
1079 clone_role = a_role;
1098 if (pe_rsc_is_clone(rsc)) {
1099 clone_variant_data_t *clone_data = NULL;
1101 get_clone_variant_data(clone_data, rsc);
1102 if (clone_data->clone_max == g_list_length(data_set->
nodes)) {
#define CRM_CHECK(expr, failure_action)
bool is_set_recursive(pe_resource_t *rsc, long long flag, bool any)
gboolean pcmk__str_in_list(GList *lst, const gchar *s)
enum rsc_role_e(* state)(const pe_resource_t *, gboolean)
void pcmk__output_xml_pop_parent(pcmk__output_t *out)
#define XML_BOOLEAN_FALSE
#define pcmk__config_err(fmt...)
#define XML_RSC_ATTR_INCARNATION
void pe__force_anon(const char *standard, pe_resource_t *rsc, const char *rid, pe_working_set_t *data_set)
resource_object_functions_t * fns
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
int crm_parse_int(const char *text, const char *default_text)
Parse an integer value from a string.
pe_node_t * pe_find_node(GListPtr node_list, const char *uname)
#define XML_RSC_ATTR_STICKINESS
#define XML_RSC_ATTR_MASTER_NODEMAX
#define XML_RSC_ATTR_INCARNATION_MAX
void clone_free(pe_resource_t *rsc)
int pe__clone_html(pcmk__output_t *out, va_list args)
xmlNode * copy_xml(xmlNode *src_node)
const char * role2text(enum rsc_role_e role)
enum rsc_role_e clone_resource_state(const pe_resource_t *rsc, gboolean current)
gboolean clone_active(pe_resource_t *rsc, gboolean all)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define XML_CIB_TAG_RESOURCE
int pe__name_and_nvpairs_xml(pcmk__output_t *out, bool is_list, const char *tag_name, size_t pairs_count,...)
int pe__clone_xml(pcmk__output_t *out, va_list args)
struct pe_node_shared_s * details
pe_resource_t * find_clone_instance(pe_resource_t *rsc, const char *sub_id, pe_working_set_t *data_set)
void common_free(pe_resource_t *rsc)
#define pe_rsc_promotable
#define XML_RSC_ATTR_ORDERED
PCMK__OUTPUT_ARGS("cluster-summary","struct pe_working_set_t *","gboolean","gboolean","gboolean","gboolean","gboolean","gboolean")
void clone_print(pe_resource_t *rsc, const char *pre_text, long options, void *print_data)
#define XML_RSC_ATTR_INCARNATION_NODEMAX
pe_resource_t * pe__create_clone_child(pe_resource_t *rsc, pe_working_set_t *data_set)
#define XML_RSC_ATTR_TARGET_ROLE
void free_xml(xmlNode *child)
enum rsc_role_e text2role(const char *role)
gboolean crm_str_eq(const char *a, const char *b, gboolean use_case)
pe_resource_t * pe_find_resource(GListPtr rsc_list, const char *id_rh)
void(* print)(pe_resource_t *, const char *, long, void *)
#define XML_RSC_ATTR_UNIQUE
#define XML_RSC_ATTR_MASTER_MAX
#define XML_RSC_ATTR_PROMOTED_MAX
Cluster status and scheduling.
int pe__clone_text(pcmk__output_t *out, va_list args)
void add_hash_param(GHashTable *hash, const char *name, const char *value)
bool pcmk__rsc_is_filtered(pe_resource_t *rsc, GListPtr only_show)
gboolean clone_unpack(pe_resource_t *rsc, pe_working_set_t *data_set)
#define status_print(fmt, args...)
This structure contains everything that makes up a single output formatter.
char * pcmk__add_word(char *list, const char *word)
void(* free)(pe_resource_t *)
#define XML_RSC_ATTR_PROMOTED_NODEMAX
bool pe__is_universal_clone(pe_resource_t *rsc, pe_working_set_t *data_set)
#define pe_rsc_failure_ignored
pe_node_t *(* location)(const pe_resource_t *, GList **, int)
gboolean common_unpack(xmlNode *xml_obj, pe_resource_t **rsc, pe_resource_t *parent, pe_working_set_t *data_set)
gboolean crm_is_true(const char *s)
#define XML_CIB_TAG_GROUP
void set_bit_recursive(pe_resource_t *rsc, unsigned long long flag)
#define pe_rsc_trace(rsc, fmt, args...)
gboolean(* active)(pe_resource_t *, gboolean)
gint sort_node_uname(gconstpointer a, gconstpointer b)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
enum crm_ais_msg_types type
GHashTable * allowed_nodes