File: pcmki_simulate.h

package info (click to toggle)
pacemaker 3.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 68,576 kB
  • sloc: xml: 160,564; ansic: 143,744; python: 5,670; sh: 2,969; makefile: 2,426
file content (104 lines) | stat: -rw-r--r-- 4,023 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
 * Copyright 2021-2025 the Pacemaker project contributors
 *
 * The version control history for this file may have further details.
 *
 * This source code is licensed under the GNU Lesser General Public License
 * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
 */

#ifndef PCMK__PCMKI_PCMKI_SIMULATE__H
#define PCMK__PCMKI_PCMKI_SIMULATE__H

#include <crm/common/output_internal.h>
#include <crm/common/scheduler.h>
#include <pcmki/pcmki_transition.h>
#include <crm/cib.h>                    // cib_t
#include <pacemaker.h>
#include <stdbool.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/*!
 * \internal
 * \brief Profile the configuration updates and scheduler actions in every
 *        CIB file in a given directory, printing the profiling timings for
 *        each.
 *
 * \param[in,out] out       Output object
 * \param[in]     flags     Group of <tt>enum pcmk_sim_flags</tt>
 * \param[in]     dir       Directory full of CIB files to be profiled
 * \param[in]     repeat    Number of times to run on each input file
 * \param[in]     use_date  Date to set the cluster's time to (can be \c NULL)
 *
 * \return Standard Pacemaker return code
 */
int pcmk__profile_dir(pcmk__output_t *out, uint32_t flags, const char *dir,
                      unsigned int repeat, const char *use_date);

/*!
 * \internal
 * \brief Simulate executing a transition
 *
 * \param[in,out] scheduler     Scheduler data
 * \param[in,out] cib           CIB object for scheduler input
 * \param[in]     op_fail_list  List of actions to simulate as failing
 *
 * \return Transition status after simulated execution
 */
enum pcmk__graph_status pcmk__simulate_transition(pcmk_scheduler_t *scheduler,
                                                  cib_t *cib,
                                                  const GList *op_fail_list);

/*!
 * \internal
 * \brief Simulate a cluster's response to events
 *
 * This high-level function essentially implements crm_simulate(8).  It operates
 * on an input CIB file and various lists of events that can be simulated.  It
 * optionally writes out a variety of artifacts to show the results of the
 * simulation.  Output can be modified with various flags.
 *
 * \param[in,out] scheduler    Scheduler data
 * \param[in,out] out          The output functions structure
 * \param[in]     injections   A structure containing cluster events
 *                             (node up/down, tickets, injected operations)
 *                             and related data
 * \param[in]     flags        Group of <tt>enum pcmk_sim_flags</tt>
 * \param[in]     section_opts Which portions of the cluster status output
 *                             should be displayed?
 * \param[in]     use_date     The date to set the cluster's time to
 *                             (may be NULL)
 * \param[in]     input_file   The source CIB file, which may be overwritten by
 *                             this function (may be NULL)
 * \param[in]     graph_file   Where to write the XML-formatted transition graph
 *                             (may be NULL, in which case no file will be
 *                             written)
 * \param[in]     dot_file     Where to write the dot(1) formatted transition
 *                             graph (may be NULL, in which case no file will
 *                             be written; see \p pcmk__write_sim_dotfile())
 *
 * \return Standard Pacemaker return code
 */
int pcmk__simulate(pcmk_scheduler_t *scheduler, pcmk__output_t *out,
                   const pcmk_injections_t *injections, uint32_t flags,
                   uint32_t section_opts, const char *use_date,
                   const char *input_file, const char *graph_file,
                   const char *dot_file);

/*!
 * \internal
 *
 * If this global is set to true, simulations will add nodes to the
 * CIB configuration section, as well as the status section.
 */
extern bool pcmk__simulate_node_config;

#ifdef __cplusplus
}
#endif

#endif // PCMK__PCMKI_PCMKI_SIMULATE__H