14 int node_weight,
const char *discover_mode,
19 if (rsc == NULL ||
id == NULL) {
23 }
else if (foo_node == NULL) {
28 if (new_con != NULL) {
29 new_con->
id = strdup(
id);
35 if (discover_mode == NULL ||
safe_str_eq(discover_mode,
"always")) {
39 }
else if (
safe_str_eq(discover_mode,
"exclusive")) {
46 if (foo_node != NULL) {
49 copy->
weight = node_weight;
75 crm_trace(
"%s: online=%d, unclean=%d, standby=%d, maintenance=%d",
83 struct node_weight_s {
93 sort_node_weight(gconstpointer a, gconstpointer b, gpointer
data)
97 struct node_weight_s *nw =
data;
100 int node2_weight = 0;
111 node1_weight = node1->
weight;
112 node2_weight = node2->
weight;
121 if (node1_weight > node2_weight) {
127 if (node1_weight < node2_weight) {
136 if (
safe_str_eq(nw->data_set->placement_strategy,
"minimal")) {
140 if (
safe_str_eq(nw->data_set->placement_strategy,
"balanced")) {
146 }
else if (result > 0) {
155 crm_trace(
"%s (%d) > %s (%d) : resources",
161 crm_trace(
"%s (%d) < %s (%d) : resources",
167 if (nw->active && nw->active->details == node1->
details) {
172 }
else if (nw->active && nw->active->details == node2->
details) {
187 struct node_weight_s nw = { active_node, data_set };
189 return g_list_sort_with_data(nodes, sort_node_weight, &nw);
215 if (force == FALSE && chosen != NULL) {
227 crm_debug(
"All nodes for resource %s are unavailable"
228 ", unclean or shutting down (%s: %d, %d)",
242 if (chosen == NULL) {
246 crm_debug(
"Could not allocate a node for %s", rsc->
id);
249 for (gIter = rsc->
actions; gIter != NULL; gIter = gIter->next) {
261 }
else if (interval_ms_s &&
safe_str_neq(interval_ms_s,
"0")) {
291 const char *node_uname = NULL;
292 const char *node_uuid = NULL;
294 if (action == NULL) {
295 crm_trace(
"%s%s: <NULL>", pre_text == NULL ?
"" : pre_text, pre_text == NULL ?
"" :
": ");
303 }
else if (action->
node != NULL) {
307 node_uname =
"<none>";
314 crm_trace(
"%s%s%sAction %d: %s%s%s%s%s%s",
315 pre_text == NULL ?
"" : pre_text,
316 pre_text == NULL ?
"" :
": ",
317 is_set(action->
flags,
320 "Optional " : is_set(action->
flags,
323 ?
"" :
"(Provisional) " :
"!!Non-Startable!! ", action->
id,
324 action->
uuid, node_uname ?
"\ton " :
"",
325 node_uname ? node_uname :
"", node_uuid ?
"\t\t(" :
"",
326 node_uuid ? node_uuid :
"", node_uuid ?
")" :
"");
329 crm_trace(
"%s%s%sAction %d: %s %s%s%s%s%s%s",
330 pre_text == NULL ?
"" : pre_text,
331 pre_text == NULL ?
"" :
": ",
332 is_set(action->
flags,
335 ?
"Pseudo " : is_set(action->
flags,
338 ?
"" :
"(Provisional) " :
"!!Non-Startable!! ", action->
id,
340 node_uname ?
"\ton " :
"", node_uname ? node_uname :
"",
341 node_uuid ?
"\t\t(" :
"", node_uuid ? node_uuid :
"", node_uuid ?
")" :
"");
349 crm_trace(
"\t\t====== Preceding Actions");
352 for (; gIter != NULL; gIter = gIter->next) {
358 crm_trace(
"\t\t====== Subsequent Actions");
361 for (; gIter != NULL; gIter = gIter->next) {
385 g_hash_table_iter_init(&iter, nodes);
386 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
432 free(cancel_op->
task);
464 node, FALSE, TRUE, data_set);
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)
enum rsc_role_e role_filter
#define crm_notice(fmt, args...)
void dump_rsc_utilization(int level, const char *comment, resource_t *rsc, node_t *node)
gboolean safe_str_neq(const char *a, const char *b)
void native_deallocate(resource_t *rsc)
int compare_capacity(const node_t *node1, const node_t *node2)
GList * sort_nodes_by_weight(GList *nodes, pe_node_t *active_node, pe_working_set_t *data_set)
node_t * node_copy(const node_t *this_node)
int utilization_log_level
enum rsc_role_e next_role
gboolean exclusive_discover
pe_action_t * sched_shutdown_op(pe_node_t *node, pe_working_set_t *data_set)
#define XML_LOCATION_ATTR_DISCOVERY
enum action_tasks text2task(const char *task)
#define clear_bit(word, bit)
gboolean native_assign_node(resource_t *rsc, GListPtr candidates, node_t *chosen, gboolean force)
void calculate_utilization(GHashTable *current_utilization, GHashTable *utilization, gboolean plus)
GListPtr placement_constraints
#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)
enum pe_discover_e discover_mode
#define set_bit(word, bit)
gboolean pe__is_guest_node(pe_node_t *node)
#define crm_debug(fmt, args...)
void log_action(unsigned int log_level, const char *pre_text, action_t *action, gboolean details)
#define crm_trace(fmt, args...)
struct pe_node_shared_s * details
#define XML_ATTR_TE_NOWAIT
action_t * custom_action(resource_t *rsc, char *key, const char *task, node_t *on_node, gboolean optional, gboolean foo, pe_working_set_t *data_set)
enum pe_obj_types variant
gboolean can_run_resources(const node_t *node)
gboolean can_run_any(GHashTable *nodes)
gboolean show_utilization
pe_action_t * create_pseudo_resource_op(resource_t *rsc, const char *task, bool optional, bool runnable, pe_working_set_t *data_set)
void add_hash_param(GHashTable *hash, const char *name, const char *value)
gboolean update_action_flags(action_t *action, enum pe_action_flags flags, const char *source, int line)
#define XML_LRM_ATTR_INTERVAL_MS
enum pe_action_flags flags
#define safe_str_eq(a, b)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
#define crm_info(fmt, args...)
char * generate_op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key.
gboolean shutdown_constraints(node_t *node, action_t *shutdown_op, pe_working_set_t *data_set)
#define XML_ATTR_TE_TARGET_RC