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)
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(
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);
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;
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);
565 if (options & pe_print_html) {
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)) {
#define CRM_CHECK(expr, failure_action)
gboolean clone_unpack(resource_t *rsc, pe_working_set_t *data_set)
#define XML_BOOLEAN_FALSE
#define crm_config_err(fmt...)
#define XML_RSC_ATTR_INCARNATION
bool pe__is_universal_clone(pe_resource_t *rsc, pe_working_set_t *data_set)
void pe__force_anon(const char *standard, pe_resource_t *rsc, const char *rid, pe_working_set_t *data_set)
gboolean common_unpack(xmlNode *xml_obj, resource_t **rsc, resource_t *parent, pe_working_set_t *data_set)
void common_free(resource_t *rsc)
resource_object_functions_t * fns
#define status_print(fmt, args...)
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
void set_bit_recursive(resource_t *rsc, unsigned long long flag)
gboolean clone_active(resource_t *rsc, gboolean all)
#define XML_RSC_ATTR_MASTER_NODEMAX
#define XML_RSC_ATTR_INCARNATION_MAX
xmlNode * copy_xml(xmlNode *src_node)
const char * role2text(enum rsc_role_e role)
pe_node_t *(* location)(const pe_resource_t *, GList **, int)
void clone_free(resource_t *rsc)
enum rsc_role_e clone_resource_state(const resource_t *rsc, gboolean current)
char * add_list_element(char *list, const char *value)
#define XML_CIB_TAG_RESOURCE
struct pe_node_shared_s * details
#define XML_RSC_ATTR_ORDERED
void(* print)(pe_resource_t *, const char *, long, void *)
#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)(pe_resource_t *)
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)
const char * crm_element_value(const xmlNode *data, const char *name)
pe_resource_t * pe_find_resource(GListPtr rsc_list, const char *id_rh)
#define XML_RSC_ATTR_UNIQUE
void clone_print(resource_t *rsc, const char *pre_text, long options, void *print_data)
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
enum rsc_role_e(* state)(const pe_resource_t *, gboolean)
#define XML_RSC_ATTR_MASTER_MAX
#define XML_RSC_ATTR_PROMOTED_MAX
Cluster status and scheduling.
void add_hash_param(GHashTable *hash, const char *name, const char *value)
#define pe_rsc_promotable
#define pe_rsc_failure_ignored
resource_t * find_clone_instance(resource_t *rsc, const char *sub_id, pe_working_set_t *data_set)
bool is_set_recursive(resource_t *rsc, long long flag, bool any)
#define XML_RSC_ATTR_PROMOTED_NODEMAX
gboolean crm_is_true(const char *s)
#define XML_CIB_TAG_GROUP
#define pe_rsc_trace(rsc, fmt, args...)
void print_resource(int log_level, const char *pre_text, resource_t *rsc, gboolean details)
#define XML_RSC_ATTR_INTERLEAVE
gint sort_node_uname(gconstpointer a, gconstpointer b)
enum crm_ais_msg_types type
gboolean(* active)(pe_resource_t *, gboolean)
GHashTable * allowed_nodes