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;
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);
277 if (force == FALSE && chosen != NULL) {
289 crm_debug(
"All nodes for resource %s are unavailable"
290 ", unclean or shutting down (%s: %d, %d)",
304 if (chosen == NULL) {
308 crm_debug(
"Could not allocate a node for %s", rsc->
id);
311 for (gIter = rsc->
actions; gIter != NULL; gIter = gIter->next) {
325 }
else if (interval_ms_s && !pcmk__str_eq(interval_ms_s,
"0",
pcmk__str_casei)) {
350 out->
message(out,
"resource-util", rsc, chosen, __func__);
359 const char *node_uname = NULL;
360 const char *node_uuid = NULL;
361 const char *desc = NULL;
363 if (action == NULL) {
364 crm_trace(
"%s%s: <NULL>", pre_text == NULL ?
"" : pre_text, pre_text == NULL ?
"" :
": ");
372 }
else if (action->
node != NULL) {
376 node_uname =
"<none>";
388 desc =
"!!Non-Startable!! ";
392 desc =
"(Provisional) ";
394 crm_trace(
"%s%s%sAction %d: %s%s%s%s%s%s",
395 ((pre_text == NULL)?
"" : pre_text),
396 ((pre_text == NULL)?
"" :
": "),
397 desc, action->
id, action->
uuid,
398 (node_uname?
"\ton " :
""), (node_uname? node_uname :
""),
399 (node_uuid?
"\t\t(" :
""), (node_uuid? node_uuid :
""),
400 (node_uuid?
")" :
""));
408 desc =
"!!Non-Startable!! ";
412 desc =
"(Provisional) ";
414 crm_trace(
"%s%s%sAction %d: %s %s%s%s%s%s%s",
415 ((pre_text == NULL)?
"" : pre_text),
416 ((pre_text == NULL)?
"" :
": "),
417 desc, action->
id, action->
uuid,
418 (action->
rsc? action->
rsc->
id :
"<none>"),
419 (node_uname?
"\ton " :
""), (node_uname? node_uname :
""),
420 (node_uuid?
"\t\t(" :
""), (node_uuid? node_uuid :
""),
421 (node_uuid?
")" :
""));
428 crm_trace(
"\t\t====== Preceding Actions");
431 for (; gIter != NULL; gIter = gIter->next) {
437 crm_trace(
"\t\t====== Subsequent Actions");
440 for (; gIter != NULL; gIter = gIter->next) {
464 g_hash_table_iter_init(&iter, nodes);
465 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
478 task, NULL, optional, TRUE, data_set);
512 free(cancel_op->
task);
541 node, FALSE, TRUE, data_set);
550 generate_transition_magic(
const char *transition_key,
int op_status,
int op_rc)
552 CRM_CHECK(transition_key != NULL,
return NULL);
558 const char *magic,
int level)
565 xmlNode *args_xml = NULL;
581 do_crm_log(level,
"Calculated digest %s for %s (%s). Source: %s\n",
582 digest,
ID(update), magic, digest_source);
592 #define FAKE_TE_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
610 const char *caller_version,
int target_rc,
611 const char *node,
const char *origin,
int level)
616 char *op_id_additional = NULL;
617 char *local_user_data = NULL;
618 const char *exit_reason = NULL;
620 xmlNode *xml_op = NULL;
621 const char *task = NULL;
624 do_crm_log(level,
"%s: Updating resource %s after %s op %s (interval=%u)",
628 crm_trace(
"DC version: %s", caller_version);
686 if (xml_op == NULL) {
721 "): last=%u change=%u exec=%u queue=%u",
731 (
long long) op->
t_run);
751 append_digest(op, xml_op, caller_version, magic, LOG_DEBUG);
753 if (op_id_additional) {
755 op_id = op_id_additional;
756 op_id_additional = NULL;
760 if (local_user_data) {
761 free(local_user_data);
775 const char* argv[] = {
"", NULL };
784 crm_err(
"Can't log resource details due to internal error: %s\n",
GList * pcmk__copy_node_list(const GList *list, bool reset)
pe_action_t * pe_cancel_op(pe_resource_t *rsc, const char *name, guint interval_ms, pe_node_t *node, pe_working_set_t *data_set)
#define CRM_CHECK(expr, failure_action)
#define XML_RSC_OP_LAST_CHANGE
enum rsc_role_e role_filter
#define PCMK__SUPPORTED_FORMAT_LOG
#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 * sort_nodes_by_weight(GList *nodes, pe_node_t *active_node, pe_working_set_t *data_set)
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
pe_action_t * sched_shutdown_op(pe_node_t *node, pe_working_set_t *data_set)
gboolean native_assign_node(pe_resource_t *rsc, pe_node_t *chosen, gboolean force)
#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
int(* message)(pcmk__output_t *out, const char *message_id,...)
void pcmk__filter_op_for_digest(xmlNode *param_set)
enum action_tasks text2task(const char *task)
#define CRM_LOG_ASSERT(expr)
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
void pcmk__register_formats(GOptionGroup *group, pcmk__supported_format_t *table)
#define XML_RSC_OP_T_QUEUE
gboolean can_run_resources(const pe_node_t *node)
#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
#define pe_rsc_provisional
#define XML_LRM_ATTR_TASK
pe__location_t * rsc2node_new(const char *id, pe_resource_t *rsc, int weight, const char *discovery_mode, pe_node_t *node, pe_working_set_t *data_set)
char * calculate_operation_digest(xmlNode *local_cib, const char *version)
Calculate and return digest of XML operation.
enum pe_discover_e discover_mode
#define CRMD_ACTION_RELOAD_AGENT
char * pcmk__notify_key(const char *rsc_id, const char *notify_type, const char *op_type)
pe_action_t * create_pseudo_resource_op(pe_resource_t *rsc, const char *task, bool optional, bool runnable, pe_working_set_t *data_set)
#define crm_debug(fmt, args...)
pcmk__output_t * pcmk__new_logger(void)
bool pe__is_guest_node(const pe_node_t *node)
xmlNode * pcmk__create_history_xml(xmlNode *parent, lrmd_event_data_t *event, const char *caller_version, int target_rc, const char *node, const char *origin, int level)
#define crm_trace(fmt, args...)
#define do_crm_log(level, fmt, args...)
Log a message.
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
struct pe_node_shared_s * details
void pcmk__register_lib_messages(pcmk__output_t *out)
#define XML_ATTR_TE_NOWAIT
xmlNode * create_xml_node(xmlNode *parent, const char *name)
#define XML_LRM_ATTR_MIGRATE_TARGET
#define XML_LRM_ATTR_EXIT_REASON
void pe__register_messages(pcmk__output_t *out)
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
gboolean can_run_any(GHashTable *nodes)
char * pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key (RESOURCE_ACTION_INTERVAL)
#define CRMD_ACTION_RELOAD
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.
GHashTable * pcmk__copy_node_table(GHashTable *nodes)
#define XML_ATTR_TRANSITION_KEY
unsigned int get_crm_log_level(void)
void log_action(unsigned int log_level, const char *pre_text, pe_action_t *action, gboolean details)
GHashTable * pcmk__strkey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
void add_hash_param(GHashTable *hash, const char *name, const char *value)
#define pe_flag_show_utilization
gboolean did_rsc_op_fail(lrmd_event_data_t *event, int target_rc)
#define crm_err(fmt, args...)
void pe__set_next_role(pe_resource_t *rsc, enum rsc_role_e role, const char *why)
This structure contains everything that makes up a single output formatter.
int compare_version(const char *version1, const char *version2)
#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)
enum pe_action_flags flags
GList * placement_constraints
pe_working_set_t * cluster
int pcmk__output_new(pcmk__output_t **out, const char *fmt_name, const char *filename, char **argv)
void native_deallocate(pe_resource_t *rsc)
#define XML_LRM_ATTR_TARGET
#define XML_LRM_TAG_RSC_OP
int compare_capacity(const pe_node_t *node1, const pe_node_t *node2)
#define XML_LRM_ATTR_MIGRATE_SOURCE
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