27 #define VARIANT_CLONE 1
40 for (; gIter != NULL; gIter = gIter->next) {
43 mark_as_orphan(child);
50 if (pe_rsc_is_clone(rsc)) {
51 clone_variant_data_t *clone_data = NULL;
53 get_clone_variant_data(clone_data, rsc);
56 "can only be used as an anonymous clone. "
59 clone_data->clone_node_max = 1;
60 clone_data->clone_max = g_list_length(data_set->
nodes);
68 char *child_id = NULL;
70 const char *child_base = NULL;
71 clone_variant_data_t *clone_data = NULL;
73 get_clone_variant_data(clone_data, rsc);
75 child_base =
ID(clone_data->xml_obj_child);
76 child_id =
crm_concat(child_base, sub_id,
':');
86 gboolean as_orphan = FALSE;
90 xmlNode *child_copy = NULL;
91 clone_variant_data_t *clone_data = NULL;
93 get_clone_variant_data(clone_data, rsc);
95 CRM_CHECK(clone_data->xml_obj_child != NULL,
return FALSE);
99 sub_id = clone_data->total_clones;
102 inc_max =
crm_itoa(clone_data->clone_max);
104 child_copy =
copy_xml(clone_data->xml_obj_child);
108 if (
common_unpack(child_copy, &child_rsc, rsc, data_set) == FALSE) {
116 clone_data->total_clones += 1;
117 pe_rsc_trace(child_rsc,
"Setting clone attributes for: %s", child_rsc->
id);
120 mark_as_orphan(child_rsc);
142 clone_variant_data_t *clone_data = NULL;
144 get_clone_variant_data(clone_data, rsc);
146 clone_data->master_node_max =
crm_parse_int(master_node_max,
"1");
156 xmlNode *a_child = NULL;
157 xmlNode *xml_obj = rsc->
xml;
158 clone_variant_data_t *clone_data = NULL;
167 clone_data = calloc(1,
sizeof(clone_variant_data_t));
170 clone_data->active_clones = 0;
171 clone_data->xml_obj_child = NULL;
172 clone_data->clone_node_max =
crm_parse_int(max_clones_node,
"1");
177 }
else if (g_list_length(data_set->
nodes) > 0) {
178 clone_data->clone_max = g_list_length(data_set->
nodes);
181 clone_data->clone_max = 1;
188 crm_config_err(
"Anonymous clones (%s) may only support one copy per node", rsc->
id);
189 clone_data->clone_node_max = 1;
193 pe_rsc_trace(rsc,
"\tClone max: %d", clone_data->clone_max);
194 pe_rsc_trace(rsc,
"\tClone node max: %d", clone_data->clone_node_max);
199 for (a_child = __xml_first_child(xml_obj); a_child != NULL;
200 a_child = __xml_next_element(a_child)) {
204 clone_data->xml_obj_child = a_child;
209 if (clone_data->xml_obj_child == NULL) {
230 for (lpc = 0; lpc < clone_data->clone_max; lpc++) {
236 if (clone_data->clone_max == 0) {
245 pe_rsc_trace(rsc,
"Added %d children to resource %s...", clone_data->clone_max, rsc->
id);
254 for (; gIter != NULL; gIter = gIter->next) {
256 gboolean child_active = child_rsc->
fns->
active(child_rsc, all);
258 if (all == FALSE && child_active) {
260 }
else if (all && child_active == FALSE) {
273 short_print(
char *list,
const char *prefix,
const char *
type,
const char *suffix,
long options,
void *print_data)
283 status_print(
"%s%s: [%s ]%s", prefix, type, list, suffix);
285 if (options & pe_print_html) {
300 const char *target_role = g_hash_table_lookup(rsc->
meta,
313 const char *target_role = configured_role_str(rsc);
322 clone_print_xml(
resource_t * rsc,
const char *pre_text,
long options,
void *print_data)
325 char *child_text =
crm_concat(pre_text,
" ",
' ');
326 const char *target_role = configured_role_str(rsc);
331 status_print(
"multi_state=\"%s\" ", is_master_slave ?
"true" :
"false");
342 for (; gIter != NULL; gIter = gIter->next) {
345 child_rsc->
fns->
print(child_rsc, child_text, options, print_data);
357 if(is_set(rsc->
flags, flag)) {
365 for (gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
385 char *list_text = NULL;
386 char *child_text = NULL;
387 char *stopped_list = NULL;
388 const char *type =
"Clone";
394 clone_variant_data_t *clone_data = NULL;
395 int active_instances = 0;
397 if (pre_text == NULL) {
402 clone_print_xml(rsc, pre_text, options, print_data);
406 get_clone_variant_data(clone_data, rsc);
411 type =
"Master/Slave";
415 pre_text ? pre_text :
"", type, rsc->
id,
ID(clone_data->xml_obj_child),
419 if (options & pe_print_html) {
426 for (; gIter != NULL; gIter = gIter->next) {
427 gboolean print_full = FALSE;
434 if (child_rsc->
fns->
active(child_rsc, FALSE) == FALSE) {
458 }
else if (child_rsc->
fns->
active(child_rsc, TRUE)) {
470 master_list = g_list_append(master_list, location);
474 started_list = g_list_append(started_list, location);
488 if (options & pe_print_html) {
491 child_rsc->
fns->
print(child_rsc, child_text, options, print_data);
492 if (options & pe_print_html) {
500 for (gIter = master_list; gIter; gIter = gIter->next) {
507 short_print(list_text, child_text,
"Masters", NULL, options, print_data);
508 g_list_free(master_list);
514 for (gIter = started_list; gIter; gIter = gIter->next) {
525 short_print(list_text, child_text,
"Slaves (target-role)", NULL, options, print_data);
527 short_print(list_text, child_text,
"Slaves", NULL, options, print_data);
531 short_print(list_text, child_text,
"Started", NULL, options, print_data);
534 g_list_free(started_list);
539 const char *state =
"Stopped";
543 state =
"Stopped (disabled)";
547 && (clone_data->clone_max > active_instances)) {
553 free(stopped_list); stopped_list = NULL;
555 if (g_list_length(list) == 0) {
559 list = g_hash_table_get_values(rsc->
known_on);
563 for (nIter = list; nIter != NULL; nIter = nIter->next) {
573 short_print(stopped_list, child_text, state, NULL, options, print_data);
577 if (options & pe_print_html) {
588 clone_variant_data_t *clone_data = NULL;
590 get_clone_variant_data(clone_data, rsc);
594 for (; gIter != NULL; gIter = gIter->next) {
600 child_rsc->
xml = NULL;
604 child_rsc->
fns->
free(child_rsc);
610 CRM_ASSERT(clone_data->demote_notify == NULL);
613 CRM_ASSERT(clone_data->promote_notify == NULL);
625 for (; gIter != NULL; gIter = gIter->next) {
629 if (a_role > clone_role) {
#define CRM_CHECK(expr, failure_action)
void clone_print(resource_t *rsc, const char *pre_text, long options, void *print_data)
node_t *(* location)(resource_t *, GListPtr *, gboolean)
#define XML_BOOLEAN_FALSE
#define crm_config_err(fmt...)
#define XML_RSC_ATTR_INCARNATION
gboolean common_unpack(xmlNode *xml_obj, resource_t **rsc, resource_t *parent, pe_working_set_t *data_set)
enum pe_obj_types variant
void(* free)(resource_t *)
void common_free(resource_t *rsc)
#define status_print(fmt, args...)
int crm_parse_int(const char *text, const char *default_text)
node_t * pe_find_node(GListPtr node_list, const char *uname)
#define XML_RSC_ATTR_STICKINESS
void force_non_unique_clone(resource_t *rsc, const char *rid, pe_working_set_t *data_set)
#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)
gboolean(* active)(resource_t *, gboolean)
struct node_shared_s * details
#define set_bit(word, bit)
char * add_list_element(char *list, const char *value)
#define XML_CIB_TAG_RESOURCE
resource_object_functions_t * fns
GHashTable * allowed_nodes
#define XML_RSC_ATTR_ORDERED
const char * crm_element_value(xmlNode *data, const char *name)
#define XML_RSC_ATTR_INCARNATION_NODEMAX
#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)
enum rsc_role_e clone_resource_state(const resource_t *rsc, gboolean current)
#define XML_RSC_ATTR_UNIQUE
#define crm_config_warn(fmt...)
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
#define XML_RSC_ATTR_MASTER_MAX
gboolean clone_active(resource_t *rsc, gboolean all)
resource_t * create_child_clone(resource_t *rsc, int sub_id, pe_working_set_t *data_set)
void add_hash_param(GHashTable *hash, const char *name, const char *value)
void(* print)(resource_t *, const char *, long, void *)
enum rsc_role_e(* state)(const resource_t *, gboolean)
#define pe_rsc_failure_ignored
void clear_bit_recursive(resource_t *rsc, unsigned long long flag)
gboolean crm_is_true(const char *s)
#define XML_CIB_TAG_GROUP
#define pe_rsc_trace(rsc, fmt, args...)
char * crm_concat(const char *prefix, const char *suffix, char join)
void print_resource(int log_level, const char *pre_text, resource_t *rsc, gboolean details)
char * crm_itoa(int an_int)
resource_t * pe_find_resource(GListPtr rsc_list, const char *id_rh)
#define XML_RSC_ATTR_INTERLEAVE
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)
gboolean master_unpack(resource_t *rsc, pe_working_set_t *data_set)