pacemaker  2.1.5-b7adf64e51
Scalable High-Availability cluster resource manager
options_internal.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006-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__OPTIONS_INTERNAL__H
11 # define PCMK__OPTIONS_INTERNAL__H
12 
13 # ifndef PCMK__CONFIG_H
14 # define PCMK__CONFIG_H
15 # include <config.h> // HAVE_GETOPT, _Noreturn
16 # endif
17 
18 # include <glib.h> // GHashTable
19 # include <stdbool.h> // bool
20 
21 /*
22  * Command-line option handling
23  *
24  * This will all eventually go away as everything is converted to use GOption
25  */
26 
27 # ifdef HAVE_GETOPT_H
28 # include <getopt.h>
29 # else
30 # define no_argument 0
31 # define required_argument 1
32 # endif
33 
36  pcmk__option_hidden = (1 << 1),
39 };
40 
41 typedef struct pcmk__cli_option_s {
42  /* Fields from 'struct option' in getopt.h */
43  /* name of long option */
44  const char *name;
45  /*
46  * one of no_argument, required_argument, and optional_argument:
47  * whether option takes an argument
48  */
49  int has_arg;
50  /* if not NULL, set *flag to val when option found */
51  int *flag;
52  /* if flag not NULL, value to set *flag to; else return value */
53  int val;
54 
55  /* Custom fields */
56  const char *desc;
57  long flags;
59 
60 void pcmk__set_cli_options(const char *short_options, const char *usage,
61  const pcmk__cli_option_t *long_options,
62  const char *app_desc);
63 int pcmk__next_cli_option(int argc, char **argv, int *index,
64  const char **longname);
65 _Noreturn void pcmk__cli_help(char cmd, crm_exit_t exit_code);
66 void pcmk__cli_option_cleanup(void);
67 
68 
69 /*
70  * Environment variable option handling
71  */
72 
73 const char *pcmk__env_option(const char *option);
74 void pcmk__set_env_option(const char *option, const char *value);
75 bool pcmk__env_option_enabled(const char *daemon, const char *option);
76 
77 
78 /*
79  * Cluster option handling
80  */
81 
82 typedef struct pcmk__cluster_option_s {
83  const char *name;
84  const char *alt_name;
85  const char *type;
86  const char *values;
87  const char *default_value;
88 
89  bool (*is_valid)(const char *);
90 
91  const char *description_short;
92  const char *description_long;
93 
95 
96 const char *pcmk__cluster_option(GHashTable *options,
97  const pcmk__cluster_option_t *option_list,
98  int len, const char *name);
99 
100 gchar *pcmk__format_option_metadata(const char *name, const char *desc_short,
101  const char *desc_long,
102  pcmk__cluster_option_t *option_list,
103  int len);
104 
105 void pcmk__validate_cluster_options(GHashTable *options,
106  pcmk__cluster_option_t *option_list,
107  int len);
108 
109 bool pcmk__valid_interval_spec(const char *value);
110 bool pcmk__valid_boolean(const char *value);
111 bool pcmk__valid_number(const char *value);
112 bool pcmk__valid_positive_number(const char *value);
113 bool pcmk__valid_quorum(const char *value);
114 bool pcmk__valid_script(const char *value);
115 bool pcmk__valid_percentage(const char *value);
116 
117 // from watchdog.c
118 long pcmk__get_sbd_timeout(void);
120 long pcmk__auto_watchdog_timeout(void);
121 bool pcmk__valid_sbd_timeout(const char *value);
122 
123 // Constants for environment variable names
124 #define PCMK__ENV_BLACKBOX "blackbox"
125 #define PCMK__ENV_CLUSTER_TYPE "cluster_type"
126 #define PCMK__ENV_DEBUG "debug"
127 #define PCMK__ENV_LOGFACILITY "logfacility"
128 #define PCMK__ENV_LOGFILE "logfile"
129 #define PCMK__ENV_LOGPRIORITY "logpriority"
130 #define PCMK__ENV_MCP "mcp"
131 #define PCMK__ENV_NODE_START_STATE "node_start_state"
132 #define PCMK__ENV_PHYSICAL_HOST "physical_host"
133 #define PCMK__ENV_QUORUM_TYPE "quorum_type"
134 #define PCMK__ENV_SHUTDOWN_DELAY "shutdown_delay"
135 #define PCMK__ENV_STDERR "stderr"
136 
137 // Constants for cluster option names
138 #define PCMK__OPT_NODE_HEALTH_BASE "node-health-base"
139 #define PCMK__OPT_NODE_HEALTH_GREEN "node-health-green"
140 #define PCMK__OPT_NODE_HEALTH_RED "node-health-red"
141 #define PCMK__OPT_NODE_HEALTH_STRATEGY "node-health-strategy"
142 #define PCMK__OPT_NODE_HEALTH_YELLOW "node-health-yellow"
143 
144 // Constants for meta-attribute names
145 #define PCMK__META_ALLOW_UNHEALTHY_NODES "allow-unhealthy-nodes"
146 
147 // Constants for enumerated values for various options
148 #define PCMK__VALUE_CUSTOM "custom"
149 #define PCMK__VALUE_FENCING "fencing"
150 #define PCMK__VALUE_GREEN "green"
151 #define PCMK__VALUE_MIGRATE_ON_RED "migrate-on-red"
152 #define PCMK__VALUE_NONE "none"
153 #define PCMK__VALUE_NOTHING "nothing"
154 #define PCMK__VALUE_ONLY_GREEN "only-green"
155 #define PCMK__VALUE_PROGRESSIVE "progressive"
156 #define PCMK__VALUE_QUORUM "quorum"
157 #define PCMK__VALUE_RED "red"
158 #define PCMK__VALUE_UNFENCING "unfencing"
159 #define PCMK__VALUE_YELLOW "yellow"
160 
161 #endif // PCMK__OPTIONS_INTERNAL__H
bool pcmk__valid_script(const char *value)
Definition: options.c:443
const char * name
Definition: cib.c:24
bool pcmk__valid_sbd_timeout(const char *value)
Definition: watchdog.c:282
enum crm_exit_e crm_exit_t
bool(* is_valid)(const char *)
void pcmk__set_env_option(const char *option, const char *value)
Set or unset a Pacemaker environment variable option.
Definition: options.c:333
struct pcmk__cli_option_s pcmk__cli_option_t
#define _Noreturn
Definition: config.h:649
_Noreturn void pcmk__cli_help(char cmd, crm_exit_t exit_code)
Definition: options.c:195
const char * pcmk__env_option(const char *option)
Definition: options.c:290
struct pcmk__cluster_option_s pcmk__cluster_option_t
bool pcmk__valid_positive_number(const char *value)
Definition: options.c:428
pcmk__cli_option_flags
bool pcmk__valid_quorum(const char *value)
Definition: options.c:437
bool pcmk__valid_interval_spec(const char *value)
Definition: options.c:399
int daemon(int nochdir, int noclose)
long pcmk__auto_watchdog_timeout(void)
Definition: watchdog.c:274
gchar * pcmk__format_option_metadata(const char *name, const char *desc_short, const char *desc_long, pcmk__cluster_option_t *option_list, int len)
Definition: options.c:644
const char * pcmk__cluster_option(GHashTable *options, const pcmk__cluster_option_t *option_list, int len, const char *name)
Definition: options.c:568
bool pcmk__valid_boolean(const char *value)
Definition: options.c:406
bool pcmk__get_sbd_sync_resource_startup(void)
Definition: watchdog.c:251
void pcmk__cli_option_cleanup(void)
Definition: options.c:39
int pcmk__next_cli_option(int argc, char **argv, int *index, const char **longname)
Definition: options.c:148
bool pcmk__valid_number(const char *value)
Definition: options.c:414
void pcmk__set_cli_options(const char *short_options, const char *usage, const pcmk__cli_option_t *long_options, const char *app_desc)
Definition: options.c:105
const char * description_short
void pcmk__validate_cluster_options(GHashTable *options, pcmk__cluster_option_t *option_list, int len)
Definition: options.c:719
bool pcmk__valid_percentage(const char *value)
Definition: options.c:470
long pcmk__get_sbd_timeout(void)
Definition: watchdog.c:240
bool pcmk__env_option_enabled(const char *daemon, const char *option)
Definition: options.c:384
const char * description_long