pacemaker  3.0.0-d8340737c4
Scalable High-Availability cluster resource manager
servers.c
Go to the documentation of this file.
1 /*
2  * Copyright 2024 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 #include <crm_internal.h>
11 
12 #include <stdio.h> // NULL
13 
14 #include <crm/crm.h>
15 
16 /* Each Pacemaker subdaemon offers an IPC interface, and most exchange cluster
17  * messages as well. Particular names need to be used for logging, connecting
18  * IPC, and IPC/cluster message types.
19  *
20  * This array is indexed by enum pcmk_ipc_server and gathers all those names for
21  * easier mapping. Most members are lists with the first value listed being the
22  * "main" one returned if another value is mapped to it.
23  *
24  * @COMPAT Ideally, we'd use a single string (such as the server's
25  * crm_system_name) as the sole IPC name and sole message type for each server,
26  * making most of this unnecessary. However, backward compatiblity with older
27  * nodes involved in a rolling upgrade or Pacemaker Remote connection would
28  * be a nightmare: we'd have to add duplicate message attributes, struct
29  * members, and libqb IPC server endpoints for both the old and new names, and
30  * could drop the old names only after we no longer supported connections with
31  * older nodes.
32  */
33 static struct {
34  const char *log_name; // Readable server name for use in logs
35  const char *system_names[2]; // crm_system_name values (subdaemon names)
36  const char *ipc_names[3]; // libqb IPC names used to contact server
37  const char *message_types[3]; // IPC/cluster message types sent to server
38 } server_info[] = {
39  [pcmk_ipc_unknown] = {
40  NULL,
41  { NULL, NULL, },
42  { NULL, NULL, NULL, },
43  { NULL, NULL, NULL, },
44  },
45 
46  [pcmk_ipc_attrd] = {
47  "attribute manager",
48  { PCMK__SERVER_ATTRD, NULL, },
49  { PCMK__VALUE_ATTRD, NULL, NULL, },
50  { PCMK__VALUE_ATTRD, NULL, NULL, },
51  },
52 
53  [pcmk_ipc_based] = {
54  "CIB manager",
55  { PCMK__SERVER_BASED, NULL, },
58  { CRM_SYSTEM_CIB, NULL, NULL, },
59  },
60 
61  [pcmk_ipc_controld] = {
62  "controller",
63  { PCMK__SERVER_CONTROLD, NULL, },
64  { PCMK__VALUE_CRMD, NULL, NULL, },
66  },
67 
68  [pcmk_ipc_execd] = {
69  "executor",
71  { PCMK__VALUE_LRMD, NULL, NULL, },
72  { PCMK__VALUE_LRMD, NULL, NULL, },
73  },
74 
75  [pcmk_ipc_fenced] = {
76  "fencer",
77  { PCMK__SERVER_FENCED, NULL, },
78  { PCMK__VALUE_STONITH_NG, NULL, NULL, },
79  { PCMK__VALUE_STONITH_NG, NULL, NULL, },
80  },
81 
83  "launcher",
84  { PCMK__SERVER_PACEMAKERD, NULL, },
85  { CRM_SYSTEM_MCP, NULL, NULL, },
86  { CRM_SYSTEM_MCP, NULL, NULL, },
87  },
88 
90  "scheduler",
91  { PCMK__SERVER_SCHEDULERD, NULL, },
92  { CRM_SYSTEM_PENGINE, NULL, NULL, },
93  { CRM_SYSTEM_PENGINE, NULL, NULL, },
94  },
95 };
96 
107 const char *
109 {
110  CRM_CHECK((server > 0) && (server < PCMK__NELEM(server_info)),
111  return NULL);
112  return server_info[server].system_names[0];
113 }
114 
125 const char *
127 {
128  CRM_CHECK((server > 0) && (server < PCMK__NELEM(server_info)),
129  return NULL);
130  return server_info[server].log_name;
131 }
132 
143 const char *
145 {
146  CRM_CHECK((server > 0) && (server < PCMK__NELEM(server_info)),
147  return NULL);
148  return server_info[server].ipc_names[0];
149 }
150 
161 const char *
163 {
164  CRM_CHECK((server > 0) && (server < PCMK__NELEM(server_info)),
165  return NULL);
166  return server_info[server].message_types[0];
167 }
168 
177 enum pcmk_ipc_server
178 pcmk__parse_server(const char *text)
179 {
180  if (text == NULL) {
181  return pcmk_ipc_unknown;
182  }
183  for (enum pcmk_ipc_server server = pcmk_ipc_attrd;
184  server <= pcmk_ipc_schedulerd; ++server) {
185 
186  int name;
187 
188  for (name = 0;
189  (name < 2) && (server_info[server].system_names[name] != NULL);
190  ++name) {
191  if (strcmp(text, server_info[server].system_names[name]) == 0) {
192  return server;
193  }
194  }
195  for (name = 0;
196  (name < 3) && (server_info[server].ipc_names[name] != NULL);
197  ++name) {
198  if (strcmp(text, server_info[server].ipc_names[name]) == 0) {
199  return server;
200  }
201  }
202  for (name = 0;
203  (name < 3) && (server_info[server].message_types[name] != NULL);
204  ++name) {
205  if (strcmp(text, server_info[server].message_types[name]) == 0) {
206  return server;
207  }
208  }
209  }
210  return pcmk_ipc_unknown;
211 }
#define CRM_CHECK(expr, failure_action)
Definition: logging.h:213
#define PCMK__SERVER_BASED_RW
Definition: crm_internal.h:73
#define PCMK__VALUE_STONITH_NG
A dumping ground.
Scheduler.
Definition: ipc.h:56
#define PCMK__SERVER_REMOTED
#define PCMK__VALUE_ATTRD
const char * name
Definition: cib.c:26
#define PCMK__SERVER_ATTRD
Launcher.
Definition: ipc.h:55
const char * message_types[3]
Definition: servers.c:37
const char * pcmk__server_name(enum pcmk_ipc_server server)
Definition: servers.c:108
const char * pcmk__server_ipc_name(enum pcmk_ipc_server server)
Definition: servers.c:144
#define CRM_SYSTEM_DC
Definition: crm.h:81
#define CRM_SYSTEM_MCP
Definition: crm.h:88
#define PCMK__SERVER_SCHEDULERD
CIB manager.
Definition: ipc.h:51
pcmk_ipc_server
Available IPC interfaces.
Definition: ipc.h:48
const char * ipc_names[3]
Definition: servers.c:36
const char * log_name
Definition: servers.c:34
#define PCMK__SERVER_EXECD
const char * pcmk__server_message_type(enum pcmk_ipc_server server)
Definition: servers.c:162
#define CRM_SYSTEM_PENGINE
Definition: crm.h:86
const char * system_names[2]
Definition: servers.c:35
#define PCMK__NELEM(a)
Definition: internal.h:49
#define PCMK__SERVER_BASED_RO
Definition: crm_internal.h:72
#define PCMK__SERVER_BASED
#define CRM_SYSTEM_CIB
Definition: crm.h:83
#define CRM_SYSTEM_TENGINE
Definition: crm.h:87
Executor.
Definition: ipc.h:53
Controller.
Definition: ipc.h:52
Unknown or invalid.
Definition: ipc.h:49
#define PCMK__SERVER_CONTROLD
Fencer.
Definition: ipc.h:54
#define PCMK__SERVER_FENCED
#define PCMK__SERVER_BASED_SHM
Definition: crm_internal.h:74
#define PCMK__SERVER_PACEMAKERD
#define PCMK__VALUE_CRMD
Attribute manager.
Definition: ipc.h:50
enum pcmk_ipc_server pcmk__parse_server(const char *text)
Definition: servers.c:178
const char * pcmk__server_log_name(enum pcmk_ipc_server server)
Definition: servers.c:126
#define PCMK__VALUE_LRMD