1 /* 2 * Copyright 2021-2025 the Pacemaker project contributors 3 * 4 * The version control history for this file may have further details. 5 * 6 * This source code is licensed under the GNU Lesser General Public License 7 * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY. 8 */ 9 10 #ifndef PCMK__PCMKI_PCMKI_SIMULATE__H 11 #define PCMK__PCMKI_PCMKI_SIMULATE__H 12 13 #include <crm/common/output_internal.h> 14 #include <crm/common/scheduler.h> 15 #include <pcmki/pcmki_transition.h> 16 #include <crm/cib.h> // cib_t 17 #include <pacemaker.h> 18 #include <stdbool.h> 19 #include <stdint.h> 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 /*! 26 * \internal 27 * \brief Profile the configuration updates and scheduler actions in every 28 * CIB file in a given directory, printing the profiling timings for 29 * each. 30 * 31 * \param[in,out] out Output object 32 * \param[in] flags Group of <tt>enum pcmk_sim_flags</tt> 33 * \param[in] dir Directory full of CIB files to be profiled 34 * \param[in] repeat Number of times to run on each input file 35 * \param[in] use_date Date to set the cluster's time to (can be \c NULL) 36 * 37 * \return Standard Pacemaker return code 38 */ 39 int pcmk__profile_dir(pcmk__output_t *out, uint32_t flags, const char *dir, 40 unsigned int repeat, const char *use_date); 41 42 /*! 43 * \internal 44 * \brief Simulate executing a transition 45 * 46 * \param[in,out] scheduler Scheduler data 47 * \param[in,out] cib CIB object for scheduler input 48 * \param[in] op_fail_list List of actions to simulate as failing 49 * 50 * \return Transition status after simulated execution 51 */ 52 enum pcmk__graph_status pcmk__simulate_transition(pcmk_scheduler_t *scheduler, 53 cib_t *cib, 54 const GList *op_fail_list); 55 56 /*! 57 * \internal 58 * \brief Simulate a cluster's response to events 59 * 60 * This high-level function essentially implements crm_simulate(8). It operates 61 * on an input CIB file and various lists of events that can be simulated. It 62 * optionally writes out a variety of artifacts to show the results of the 63 * simulation. Output can be modified with various flags. 64 * 65 * \param[in,out] scheduler Scheduler data 66 * \param[in,out] out The output functions structure 67 * \param[in] injections A structure containing cluster events 68 * (node up/down, tickets, injected operations) 69 * and related data 70 * \param[in] flags Group of <tt>enum pcmk_sim_flags</tt> 71 * \param[in] section_opts Which portions of the cluster status output 72 * should be displayed? 73 * \param[in] use_date The date to set the cluster's time to 74 * (may be NULL) 75 * \param[in] input_file The source CIB file, which may be overwritten by 76 * this function (may be NULL) 77 * \param[in] graph_file Where to write the XML-formatted transition graph 78 * (may be NULL, in which case no file will be 79 * written) 80 * \param[in] dot_file Where to write the dot(1) formatted transition 81 * graph (may be NULL, in which case no file will 82 * be written; see \p pcmk__write_sim_dotfile()) 83 * 84 * \return Standard Pacemaker return code 85 */ 86 int pcmk__simulate(pcmk_scheduler_t *scheduler, pcmk__output_t *out, 87 const pcmk_injections_t *injections, uint32_t flags, 88 uint32_t section_opts, const char *use_date, 89 const char *input_file, const char *graph_file, 90 const char *dot_file); 91 92 /*! 93 * \internal 94 * 95 * If this global is set to true, simulations will add nodes to the 96 * CIB configuration section, as well as the status section. 97 */ 98 extern bool pcmk__simulate_node_config; 99 100 #ifdef __cplusplus 101 } 102 #endif 103 104 #endif // PCMK__PCMKI_PCMKI_SIMULATE__H