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;
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 (g_list_length(data_set->
nodes) > 0) {
160 clone_data->clone_max = g_list_length(data_set->
nodes);
163 clone_data->clone_max = 1;
169 crm_config_err(
"Anonymous clones (%s) may only support one copy per node", rsc->
id);
170 clone_data->clone_node_max = 1;
174 pe_rsc_trace(rsc,
"\tClone max: %d", clone_data->clone_max);
175 pe_rsc_trace(rsc,
"\tClone node max: %d", clone_data->clone_node_max);
182 for (a_child = __xml_first_child(xml_obj); a_child != NULL;
183 a_child = __xml_next_element(a_child)) {
187 clone_data->xml_obj_child = a_child;
192 if (clone_data->xml_obj_child == NULL) {
213 if (clone_data->clone_max <= 0) {
223 for (lpc = 0; lpc < clone_data->clone_max; lpc++) {
230 pe_rsc_trace(rsc,
"Added %d children to resource %s...", clone_data->clone_max, rsc->
id);
239 for (; gIter != NULL; gIter = gIter->next) {
241 gboolean child_active = child_rsc->
fns->
active(child_rsc, all);
243 if (all == FALSE && child_active) {
245 }
else if (all && child_active == FALSE) {
258 short_print(
char *list,
const char *prefix,
const char *
type,
const char *suffix,
long options,
void *print_data)
268 status_print(
"%s%s: [%s ]%s", prefix, type, list, suffix);
270 if (options & pe_print_html) {
285 const char *target_role = g_hash_table_lookup(rsc->
meta,
298 const char *target_role = configured_role_str(rsc);
307 clone_print_xml(
resource_t * rsc,
const char *pre_text,
long options,
void *print_data)
309 char *child_text = crm_concat(pre_text,
" ",
' ');
310 const char *target_role = configured_role_str(rsc);
326 for (; gIter != NULL; gIter = gIter->next) {
329 child_rsc->
fns->
print(child_rsc, child_text, options, print_data);
341 if(is_set(rsc->
flags, flag)) {
349 for (gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
369 char *list_text = NULL;
370 char *child_text = NULL;
371 char *stopped_list = NULL;
377 clone_variant_data_t *clone_data = NULL;
378 int active_instances = 0;
380 if (pre_text == NULL) {
385 clone_print_xml(rsc, pre_text, options, print_data);
389 get_clone_variant_data(clone_data, rsc);
391 child_text = crm_concat(pre_text,
" ",
' ');
394 pre_text ? pre_text :
"", rsc->
id,
ID(clone_data->xml_obj_child),
399 if (options & pe_print_html) {
406 for (; gIter != NULL; gIter = gIter->next) {
407 gboolean print_full = FALSE;
409 gboolean partially_active = child_rsc->
fns->
active(child_rsc, FALSE);
429 }
else if (partially_active == FALSE) {
443 }
else if (child_rsc->
fns->
active(child_rsc, TRUE)) {
457 master_list = g_list_append(master_list, location);
460 started_list = g_list_append(started_list, location);
474 if (options & pe_print_html) {
477 child_rsc->
fns->
print(child_rsc, child_text, options, print_data);
478 if (options & pe_print_html) {
486 for (gIter = master_list; gIter; gIter = gIter->next) {
493 short_print(list_text, child_text,
"Masters", NULL, options, print_data);
494 g_list_free(master_list);
500 for (gIter = started_list; gIter; gIter = gIter->next) {
511 short_print(list_text, child_text,
"Slaves (target-role)", NULL, options, print_data);
513 short_print(list_text, child_text,
"Slaves", NULL, options, print_data);
517 short_print(list_text, child_text,
"Started", NULL, options, print_data);
520 g_list_free(started_list);
525 const char *state =
"Stopped";
529 state =
"Stopped (disabled)";
533 && (clone_data->clone_max > active_instances)) {
539 free(stopped_list); stopped_list = NULL;
541 if (g_list_length(list) == 0) {
545 list = g_hash_table_get_values(rsc->
known_on);
549 for (nIter = list; nIter != NULL; nIter = nIter->next) {
559 short_print(stopped_list, child_text, state, NULL, options, print_data);
563 if (options & pe_print_html) {
573 clone_variant_data_t *clone_data = NULL;
575 get_clone_variant_data(clone_data, rsc);
585 child_rsc->
xml = NULL;
589 child_rsc->
fns->
free(child_rsc);
595 CRM_ASSERT(clone_data->demote_notify == NULL);
598 CRM_ASSERT(clone_data->promote_notify == NULL);
610 for (; gIter != NULL; gIter = gIter->next) {
614 if (a_role > clone_role) {
634 if (pe_rsc_is_clone(rsc)) {
635 clone_variant_data_t *clone_data = NULL;
637 get_clone_variant_data(clone_data, rsc);
638 if (clone_data->clone_max == g_list_length(data_set->
nodes)) {
#define CRM_CHECK(expr, failure_action)
void clone_print(resource_t *rsc, const char *pre_text, long options, void *print_data)
enum rsc_role_e(* state)(const pe_resource_t *, gboolean)
#define XML_BOOLEAN_FALSE
#define crm_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)
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
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
#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)
#define XML_RSC_ATTR_MASTER_NODEMAX
#define XML_RSC_ATTR_INCARNATION_MAX
void clone_free(resource_t *rsc)
xmlNode * copy_xml(xmlNode *src_node)
const char * role2text(enum rsc_role_e role)
char * add_list_element(char *list, const char *value)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define XML_CIB_TAG_RESOURCE
struct pe_node_shared_s * details
#define pe_rsc_promotable
#define XML_RSC_ATTR_ORDERED
#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 *)
enum rsc_role_e clone_resource_state(const resource_t *rsc, gboolean current)
#define XML_RSC_ATTR_UNIQUE
#define XML_RSC_ATTR_MASTER_MAX
#define XML_RSC_ATTR_PROMOTED_MAX
gboolean clone_active(resource_t *rsc, gboolean all)
Cluster status and scheduling.
void add_hash_param(GHashTable *hash, const char *name, const char *value)
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 crm_is_true(const char *s)
#define XML_CIB_TAG_GROUP
#define pe_rsc_trace(rsc, fmt, args...)
gboolean(* active)(pe_resource_t *, gboolean)
void print_resource(int log_level, const char *pre_text, resource_t *rsc, gboolean details)
resource_t * find_clone_instance(resource_t *rsc, const char *sub_id, pe_working_set_t *data_set)
gint sort_node_uname(gconstpointer a, gconstpointer b)
bool is_set_recursive(resource_t *rsc, long long flag, bool any)
enum crm_ais_msg_types type
gboolean clone_unpack(resource_t *rsc, pe_working_set_t *data_set)
GHashTable * allowed_nodes