1 /* 2 * Copyright 2021-2022 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/pengine/pe_types.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 /*! 22 * \internal 23 * \brief Profile the configuration updates and scheduler actions in every 24 * CIB file in a given directory, printing the profiling timings for 25 * each. 26 * 27 * \note \p data_set->priv must have been set to a valid \p pcmk__output_t 28 * object before this function is called. 29 * 30 * \param[in] dir A directory full of CIB files to be profiled 31 * \param[in] repeat Number of times to run on each input file 32 * \param[in,out] data_set Working set for the cluster 33 * \param[in] use_date The date to set the cluster's time to (may be NULL) 34 */ 35 void pcmk__profile_dir(const char *dir, long long repeat, pe_working_set_t *data_set, 36 const char *use_date); 37 38 /*! 39 * \internal 40 * \brief Simulate executing a transition 41 * 42 * \param[in,out] data_set Cluster working set 43 * \param[in,out] cib CIB object for scheduler input 44 * \param[in] op_fail_list List of actions to simulate as failing 45 * 46 * \return Transition status after simulated execution 47 */ 48 enum pcmk__graph_status pcmk__simulate_transition(pe_working_set_t *data_set, 49 cib_t *cib, 50 const GList *op_fail_list); 51 52 /*! 53 * \internal 54 * \brief Simulate a cluster's response to events 55 * 56 * This high-level function essentially implements crm_simulate(8). It operates 57 * on an input CIB file and various lists of events that can be simulated. It 58 * optionally writes out a variety of artifacts to show the results of the 59 * simulation. Output can be modified with various flags. 60 * 61 * \param[in,out] data_set Working set for the cluster 62 * \param[in,out] out The output functions structure 63 * \param[in] injections A structure containing cluster events 64 * (node up/down, tickets, injected operations) 65 * and related data 66 * \param[in] flags A bitfield of \p pcmk_sim_flags to modify 67 * operation of the simulation 68 * \param[in] section_opts Which portions of the cluster status output 69 * should be displayed? 70 * \param[in] use_date The date to set the cluster's time to 71 * (may be NULL) 72 * \param[in] input_file The source CIB file, which may be overwritten by 73 * this function (may be NULL) 74 * \param[in] graph_file Where to write the XML-formatted transition graph 75 * (may be NULL, in which case no file will be 76 * written) 77 * \param[in] dot_file Where to write the dot(1) formatted transition 78 * graph (may be NULL, in which case no file will 79 * be written; see \p pcmk__write_sim_dotfile()) 80 * 81 * \return Standard Pacemaker return code 82 */ 83 int pcmk__simulate(pe_working_set_t *data_set, pcmk__output_t *out, 84 const pcmk_injections_t *injections, unsigned int flags, 85 uint32_t section_opts, const char *use_date, 86 const char *input_file, const char *graph_file, 87 const char *dot_file); 88 89 /*! 90 * \internal 91 * 92 * If this global is set to true, simulations will add nodes to the 93 * CIB configuration section, as well as the status section. 94 */ 95 extern bool pcmk__simulate_node_config; 96 97 #endif