18 int node_weight,
const char *discover_mode,
23 if (rsc == NULL ||
id == NULL) {
27 }
else if (foo_node == NULL) {
32 if (new_con != NULL) {
33 new_con->
id = strdup(
id);
50 if (foo_node != NULL) {
53 copy->
weight = node_weight;
79 crm_trace(
"%s: online=%d, unclean=%d, standby=%d, maintenance=%d",
98 GHashTable *new_table = NULL;
105 new_table = g_hash_table_new_full(
crm_str_hash, g_str_equal, NULL, free);
106 g_hash_table_iter_init(&iter, nodes);
107 while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &node)) {
110 g_hash_table_insert(new_table, (gpointer) new_node->
details->
id,
128 GList *result = NULL;
130 for (
const GList *gIter = list; gIter != NULL; gIter = gIter->next) {
138 result = g_list_prepend(result, new_node);
143 struct node_weight_s {
153 sort_node_weight(gconstpointer a, gconstpointer b, gpointer
data)
157 struct node_weight_s *nw =
data;
159 int node1_weight = 0;
160 int node2_weight = 0;
171 node1_weight = node1->
weight;
172 node2_weight = node2->
weight;
181 if (node1_weight > node2_weight) {
187 if (node1_weight < node2_weight) {
196 if (pcmk__str_eq(nw->data_set->placement_strategy,
"minimal",
pcmk__str_casei)) {
200 if (pcmk__str_eq(nw->data_set->placement_strategy,
"balanced",
pcmk__str_casei)) {
206 }
else if (result > 0) {
215 crm_trace(
"%s (%d) > %s (%d) : resources",
221 crm_trace(
"%s (%d) < %s (%d) : resources",
227 if (nw->active && nw->active->details == node1->
details) {
232 }
else if (nw->active && nw->active->details == node2->
details) {
247 struct node_weight_s nw = { active_node, data_set };
249 return g_list_sort_with_data(nodes, sort_node_weight, &nw);
275 if (force == FALSE && chosen != NULL) {
287 crm_debug(
"All nodes for resource %s are unavailable" 288 ", unclean or shutting down (%s: %d, %d)",
302 if (chosen == NULL) {
306 crm_debug(
"Could not allocate a node for %s", rsc->
id);
309 for (gIter = rsc->
actions; gIter != NULL; gIter = gIter->next) {
323 }
else if (interval_ms_s && !pcmk__str_eq(interval_ms_s,
"0",
pcmk__str_casei)) {
347 __func__, rsc, chosen);
355 const char *node_uname = NULL;
356 const char *node_uuid = NULL;
357 const char *desc = NULL;
360 crm_trace(
"%s%s: <NULL>", pre_text == NULL ?
"" : pre_text, pre_text == NULL ?
"" :
": ");
368 }
else if (
action->node != NULL) {
369 node_uname =
action->node->details->uname;
370 node_uuid =
action->node->details->id;
372 node_uname =
"<none>";
384 desc =
"!!Non-Startable!! ";
388 desc =
"(Provisional) ";
390 crm_trace(
"%s%s%sAction %d: %s%s%s%s%s%s",
391 ((pre_text == NULL)?
"" : pre_text),
392 ((pre_text == NULL)?
"" :
": "),
394 (node_uname?
"\ton " :
""), (node_uname? node_uname :
""),
395 (node_uuid?
"\t\t(" :
""), (node_uuid? node_uuid :
""),
396 (node_uuid?
")" :
""));
404 desc =
"!!Non-Startable!! ";
408 desc =
"(Provisional) ";
410 crm_trace(
"%s%s%sAction %d: %s %s%s%s%s%s%s",
411 ((pre_text == NULL)?
"" : pre_text),
412 ((pre_text == NULL)?
"" :
": "),
415 (node_uname?
"\ton " :
""), (node_uname? node_uname :
""),
416 (node_uuid?
"\t\t(" :
""), (node_uuid? node_uuid :
""),
417 (node_uuid?
")" :
""));
424 crm_trace(
"\t\t====== Preceding Actions");
426 gIter =
action->actions_before;
427 for (; gIter != NULL; gIter = gIter->next) {
433 crm_trace(
"\t\t====== Subsequent Actions");
435 gIter =
action->actions_after;
436 for (; gIter != NULL; gIter = gIter->next) {
446 g_list_length(
action->actions_before), g_list_length(
action->actions_after));
460 g_hash_table_iter_init(&iter, nodes);
461 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
474 task, NULL, optional, TRUE, data_set);
508 free(cancel_op->
task);
537 node, FALSE, TRUE, data_set);
546 generate_transition_magic(
const char *transition_key,
int op_status,
int op_rc)
548 CRM_CHECK(transition_key != NULL,
return NULL);
554 const char *magic,
int level)
561 xmlNode *args_xml = NULL;
577 do_crm_log(level,
"Calculated digest %s for %s (%s). Source: %s\n",
578 digest,
ID(update), magic, digest_source);
588 #define FAKE_TE_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" 606 const char *caller_version,
int target_rc,
607 const char *node,
const char *origin,
int level)
612 char *op_id_additional = NULL;
613 char *local_user_data = NULL;
614 const char *exit_reason = NULL;
616 xmlNode *xml_op = NULL;
617 const char *task = NULL;
620 do_crm_log(level,
"%s: Updating resource %s after %s op %s (interval=%u)",
624 crm_trace(
"DC version: %s", caller_version);
675 if (xml_op == NULL) {
710 "): last=%u change=%u exec=%u queue=%u",
716 (
long long) op->
t_run);
720 (
long long) op->
t_run);
730 (
long long) op->
t_run);
750 append_digest(op, xml_op, caller_version, magic, LOG_DEBUG);
752 if (op_id_additional) {
754 op_id = op_id_additional;
755 op_id_additional = NULL;
759 if (local_user_data) {
760 free(local_user_data);
#define CRM_CHECK(expr, failure_action)
#define XML_RSC_OP_LAST_CHANGE
enum rsc_role_e role_filter
void log_action(unsigned int log_level, const char *pre_text, pe_action_t *action, gboolean details)
gboolean can_run_resources(const pe_node_t *node)
#define crm_notice(fmt, args...)
#define CRMD_ACTION_MIGRATED
void hash2field(gpointer key, gpointer value, gpointer user_data)
Set XML attribute based on hash table entry.
const char * crm_xml_add_ms(xmlNode *node, const char *name, guint ms)
Create an XML attribute with specified name and unsigned value.
#define XML_ATTR_TRANSITION_MAGIC
GList * pcmk__copy_node_list(const GList *list, bool reset)
pe_action_t * pe_cancel_op(pe_resource_t *rsc, const char *task, guint interval_ms, pe_node_t *node, pe_working_set_t *data_set)
gboolean native_assign_node(pe_resource_t *rsc, GListPtr nodes, pe_node_t *chosen, gboolean force)
xmlNode * pcmk__create_history_xml(xmlNode *parent, lrmd_event_data_t *op, const char *caller_version, int target_rc, const char *node, const char *origin, int level)
enum rsc_role_e next_role
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
Create an XML attribute with specified name and integer value.
gboolean exclusive_discover
#define CRMD_ACTION_NOTIFY
#define XML_LOCATION_ATTR_DISCOVERY
#define XML_RSC_OP_T_EXEC
const char * crm_meta_value(GHashTable *hash, const char *field)
xmlNode * pcmk__xe_match(xmlNode *parent, const char *node_name, const char *attr_n, const char *attr_v)
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
pe_node_t * pe__copy_node(const pe_node_t *this_node)
#define XML_LRM_ATTR_OP_DIGEST
pe_action_t * create_pseudo_resource_op(pe_resource_t *rsc, const char *task, bool optional, bool runnable, pe_working_set_t *data_set)
void pcmk__filter_op_for_digest(xmlNode *param_set)
enum action_tasks text2task(const char *task)
#define CRM_LOG_ASSERT(expr)
#define XML_RSC_OP_T_QUEUE
#define pe__set_resource_flags(resource, flags_to_set)
void calculate_utilization(GHashTable *current_utilization, GHashTable *utilization, gboolean plus)
#define CRMD_ACTION_START
#define XML_LRM_ATTR_TASK_KEY
GListPtr placement_constraints
#define pe_rsc_provisional
#define XML_LRM_ATTR_TASK
char * calculate_operation_digest(xmlNode *local_cib, const char *version)
Calculate and return digest of XML operation.
enum pe_discover_e discover_mode
char * pcmk__notify_key(const char *rsc_id, const char *notify_type, const char *op_type)
#define crm_debug(fmt, args...)
bool pe__is_guest_node(const pe_node_t *node)
void native_deallocate(pe_resource_t *rsc)
#define crm_trace(fmt, args...)
#define do_crm_log(level, fmt, args...)
Log a message.
GList * sort_nodes_by_weight(GList *nodes, pe_node_t *active_node, pe_working_set_t *data_set)
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
gboolean can_run_any(GHashTable *nodes)
struct pe_node_shared_s * details
#define XML_ATTR_TE_NOWAIT
xmlNode * create_xml_node(xmlNode *parent, const char *name)
GHashTable * pcmk__copy_node_table(GHashTable *nodes)
#define XML_LRM_ATTR_MIGRATE_TARGET
#define XML_LRM_ATTR_EXIT_REASON
gboolean update_action_flags(pe_action_t *action, enum pe_action_flags flags, const char *source, int line)
void free_xml(xmlNode *child)
enum pe_obj_types variant
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
char * pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key (RESOURCE_ACTION_INTERVAL)
const char * crm_xml_add_ll(xmlNode *node, const char *name, long long value)
Create an XML attribute with specified name and long long int value.
#define XML_ATTR_TRANSITION_KEY
unsigned int get_crm_log_level(void)
gboolean show_utilization
void add_hash_param(GHashTable *hash, const char *name, const char *value)
gboolean did_rsc_op_fail(lrmd_event_data_t *event, int target_rc)
int compare_version(const char *version1, const char *version2)
void dump_rsc_utilization(int level, const char *comment, pe_resource_t *rsc, pe_node_t *node)
#define XML_LRM_ATTR_INTERVAL_MS
char * dump_xml_unformatted(xmlNode *msg)
#define XML_LRM_ATTR_CALLID
#define CRMD_ACTION_MIGRATE
#define pe__clear_resource_flags(resource, flags_to_clear)
#define XML_LRM_ATTR_OPSTATUS
#define XML_ATTR_CRM_VERSION
char * pcmk__transition_key(int transition_id, int action_id, int target_rc, const char *node)
pe__location_t * rsc2node_new(const char *id, pe_resource_t *rsc, int node_weight, const char *discover_mode, pe_node_t *foo_node, pe_working_set_t *data_set)
pe_action_t * sched_shutdown_op(pe_node_t *node, pe_working_set_t *data_set)
#define XML_LRM_ATTR_TARGET
#define XML_LRM_TAG_RSC_OP
#define XML_RSC_OP_LAST_RUN
int compare_capacity(const pe_node_t *node1, const pe_node_t *node2)
#define XML_LRM_ATTR_MIGRATE_SOURCE
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
gboolean shutdown_constraints(pe_node_t *node, pe_action_t *shutdown_op, pe_working_set_t *data_set)
#define crm_info(fmt, args...)
#define XML_ATTR_TE_TARGET_RC
pe_action_t * custom_action(pe_resource_t *rsc, char *key, const char *task, pe_node_t *on_node, gboolean optional, gboolean foo, pe_working_set_t *data_set)
#define CRMD_ACTION_STATUS