18 #include <sys/types.h> 25 char *action_name = NULL;
26 const char *prefix =
"";
27 const char *action_host = NULL;
28 const char *clone_name = NULL;
29 const char *task =
action->task;
32 action_host =
action->node->details->uname;
34 action_host =
"<none>";
39 task =
action->cancel_task;
43 clone_name =
action->rsc->clone_name;
48 guint interval_ms = 0;
57 const char *n_type = g_hash_table_lookup(
action->meta,
"notify_key_type");
58 const char *n_task = g_hash_table_lookup(
action->meta,
"notify_key_operation");
76 const char *op = g_hash_table_lookup(
action->meta,
"stonith_action");
80 }
else if (
action->rsc && action_host) {
83 }
else if (action_host) {
94 action_name = with_id;
101 unsigned int section_opts,
const char *title,
bool print_spacer)
108 all = g_list_prepend(all, (gpointer)
"*");
111 out->
begin_list(out, NULL, NULL,
"%s", title);
112 out->
message(out,
"cluster-status", data_set, 0, NULL, FALSE,
127 out->
begin_list(out, NULL, NULL,
"Transition Summary");
135 char *use_date,
unsigned int flags)
137 data_set->
input = input;
138 data_set->
priv = out;
153 bool all_actions,
bool verbose)
156 FILE *dot_strm = fopen(dot_file,
"w");
158 if (dot_strm == NULL) {
162 fprintf(dot_strm,
" digraph \"g\" {\n");
163 for (gIter = data_set->
actions; gIter != NULL; gIter = gIter->next) {
165 const char *style =
"dashed";
166 const char *font =
"black";
167 const char *color =
"black";
168 char *action_name = create_action_name(
action, verbose);
178 }
else if ((
action->rsc != NULL)
198 fprintf(dot_strm,
"\"%s\" [ style=%s color=\"%s\" fontcolor=\"%s\"]\n",
199 action_name, style, color, font);
204 for (gIter = data_set->
actions; gIter != NULL; gIter = gIter->next) {
207 GList *gIter2 = NULL;
209 for (gIter2 =
action->actions_before; gIter2 != NULL; gIter2 = gIter2->next) {
212 char *before_name = NULL;
213 char *after_name = NULL;
214 const char *style =
"dashed";
215 bool optional =
true;
231 if (all_actions || !optional) {
232 before_name = create_action_name(before->
action, verbose);
233 after_name = create_action_name(
action, verbose);
234 fprintf(dot_strm,
"\"%s\" -> \"%s\" [ style = %s]\n",
235 before_name, after_name, style);
242 fprintf(dot_strm,
"}\n");
252 xmlNode *cib_object = NULL;
275 for (
int i = 0; i < repeat; ++i) {
276 xmlNode *input = (repeat == 1)? cib_object :
copy_xml(cib_object);
278 data_set->
input = input;
285 out->
message(out,
"profile", xml_file, start, end);
292 struct dirent **namelist;
294 int file_num = scandir(dir, &namelist, 0,
alphasort);
300 char buffer[FILENAME_MAX];
305 if (
'.' == namelist[file_num]->d_name[0]) {
306 free(namelist[file_num]);
311 free(namelist[file_num]);
314 snprintf(buffer,
sizeof(buffer),
"%s/%s", dir, namelist[file_num]->d_name);
315 if (stat(buffer, &prop) == 0 && S_ISREG(prop.st_mode)) {
318 free(namelist[file_num]);
330 time_t original_date = 0;
338 out->
info(out,
"Setting effective cluster time: %s", use_date);
342 }
else if (original_date) {
347 if (print_original) {
351 out->
info(out,
"Using the original execution date of: %s", when);
359 unsigned int flags,
unsigned int section_opts,
char *use_date,
360 char *input_file,
char *graph_file,
char *dot_file)
364 xmlNodePtr input = NULL;
366 bool modified =
false;
373 reset(data_set, input, out, use_date,
flags);
378 printed = out->
message(out,
"maint-mode", data_set->
flags);
383 printed = out->
info(out,
"%d of %d resource instances DISABLED and %d BLOCKED " 384 "from further action due to failure",
393 section_opts,
"Current cluster status", printed ==
pcmk_rc_ok);
415 reset(data_set, input, out, use_date,
flags);
419 if (input_file != NULL) {
433 out->
begin_list(out, NULL, NULL,
"Allocation Scores and Utilization Information");
437 out->
begin_list(out, NULL, NULL,
"Allocation Scores");
441 out->
begin_list(out, NULL, NULL,
"Utilization Information");
445 if (logger_out == NULL) {
450 data_set->
priv = logger_out;
455 if (logger_out == NULL) {
460 data_set->
priv = out;
465 if (graph_file != NULL) {
473 if (dot_file != NULL) {
484 print_transition_summary(data_set, printed ==
pcmk_rc_ok);
507 print_cluster_status(data_set, 0, section_opts,
"Revised Cluster Status",
true);
522 unsigned int flags,
unsigned int section_opts,
char *use_date,
523 char *input_file,
char *graph_file,
char *dot_file)
537 use_date, input_file, graph_file, dot_file);
void(* end_list)(pcmk__output_t *out)
#define CRM_CHECK(expr, failure_action)
#define pe__set_action_flags(action, flags_to_set)
Control output from tools.
#define crm_time_log_timeofday
bool pcmk__strcase_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
int(* message)(pcmk__output_t *out, const char *message_id,...)
struct crm_time_s crm_time_t
int(* signoff)(cib_t *cib)
xmlNode * get_object_root(const char *object_type, xmlNode *the_root)
Internal tracking for transition graph creation.
#define pe_flag_maintenance_mode
bool(* is_quiet)(pcmk__output_t *out)
int alphasort(const void *dirent1, const void *dirent2)
int pcmk__simulate(pe_working_set_t *data_set, pcmk__output_t *out, pcmk_injections_t *injections, unsigned int flags, unsigned int section_opts, char *use_date, char *input_file, char *graph_file, char *dot_file)
Simulate a cluster's response to events.
int write_xml_file(xmlNode *xml_node, const char *filename, gboolean compress)
Write XML to a file.
int(* info)(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
xmlNode * filename2xml(const char *filename)
xmlNode * pcmk__schedule_actions(pe_working_set_t *data_set, xmlNode *xml_input, crm_time_t *now)
void cib_delete(cib_t *cib)
Free all memory used by CIB connection.
void pcmk__profile_file(const char *xml_file, long long repeat, pe_working_set_t *data_set, char *use_date)
Profile the configuration updates and scheduler actions in a single CIB file, printing the profiling ...
gboolean validate_xml(xmlNode *xml_blob, const char *validation, gboolean to_logs)
int pcmk__out_prologue(pcmk__output_t **out, xmlNodePtr *xml)
#define PCMK__OUTPUT_SPACER_IF(out_obj, cond)
xmlNode * copy_xml(xmlNode *src_node)
int cib__signon_query(cib_t **cib, xmlNode **cib_object)
void pe_reset_working_set(pe_working_set_t *data_set)
Reset a working set to default state without freeing it.
void cleanup_calculations(pe_working_set_t *data_set)
Reset working set to default state without freeing it or constraints.
char * pcmk__notify_key(const char *rsc_id, const char *notify_type, const char *op_type)
int pcmk__guint_from_hash(GHashTable *table, const char *key, guint default_val, guint *result)
cib_api_operations_t * cmds
#define pe_flag_sanitized
int pcmk_simulate(xmlNodePtr *xml, pe_working_set_t *data_set, pcmk_injections_t *injections, unsigned int flags, unsigned int section_opts, char *use_date, char *input_file, char *graph_file, char *dot_file)
Simulate a cluster's response to events.
pcmk__output_t * pcmk__new_logger(void)
int pcmk__write_sim_dotfile(pe_working_set_t *data_set, const char *dot_file, bool all_actions, bool verbose)
Write out a file in dot(1) format describing the actions that will be taken by the scheduler in respo...
void pcmk__set_effective_date(pe_working_set_t *data_set, bool print_original, char *use_date)
Set the date of the cluster, either to the value given by use_date, or to the "execution-date" value ...
void pcmk__profile_dir(const char *dir, long long repeat, pe_working_set_t *data_set, char *use_date)
Profile the configuration updates and scheduler actions in every CIB file in a given directory...
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
void crm_time_set_timet(crm_time_t *target, time_t *source)
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
void pcmk__register_lib_messages(pcmk__output_t *out)
void(* finish)(pcmk__output_t *out, crm_exit_t exit_status, bool print, void **copy_dest)
void LogActions(pe_resource_t *rsc, pe_working_set_t *data_set)
xmlNode * create_xml_node(xmlNode *parent, const char *name)
int(* query)(cib_t *cib, const char *section, xmlNode **output_data, int call_options)
int crm_element_value_epoch(const xmlNode *xml, const char *name, time_t *dest)
Retrieve the seconds-since-epoch value of an XML attribute.
#define crm_time_log(level, prefix, dt, flags)
int pcmk_legacy2rc(int legacy_rc)
void modify_configuration(pe_working_set_t *data_set, cib_t *cib, pcmk_injections_t *injections)
void pe__register_messages(pcmk__output_t *out)
void free_xml(xmlNode *child)
void pcmk__out_epilogue(pcmk__output_t *out, xmlNodePtr *xml, int retval)
void LogNodeActions(pe_working_set_t *data_set)
enum transition_status run_simulation(pe_working_set_t *data_set, cib_t *cib, GList *op_fail_list)
Function and executable result codes.
char * pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key (RESOURCE_ACTION_INTERVAL)
char * crm_time_as_string(crm_time_t *dt, int flags)
void pcmk__output_free(pcmk__output_t *out)
#define pe_flag_show_utilization
gboolean cluster_status(pe_working_set_t *data_set)
crm_time_t * crm_time_new(const char *string)
Synthetic cluster events that can be injected into the cluster for running simulations.
This structure contains everything that makes up a single output formatter.
#define XML_LRM_ATTR_INTERVAL_MS
void(* begin_list)(pcmk__output_t *out, const char *singular_noun, const char *plural_noun, const char *format,...) G_GNUC_PRINTF(4
#define pe__set_working_set_flags(working_set, flags_to_set)
enum pe_action_flags flags
#define XML_CIB_TAG_STATUS
Data types for cluster status.
gboolean cli_config_update(xmlNode **xml, int *best_version, gboolean to_logs)
#define pe_flag_show_scores
#define crm_time_log_date
bool pcmk__ends_with_ext(const char *s, const char *match)