45
47
#include <netinet/in.h>
46
48
#include <arpa/inet.h>
48
#include <corosync/saAis.h>
50
#include <corosync/corotypes.h>
51
#include <corosync/totem/totem.h>
49
52
#include <corosync/cfg.h>
51
54
static void ringstatusget_do (void)
54
57
corosync_cfg_handle_t handle;
55
58
unsigned int interface_count;
56
59
char **interface_names;
57
60
char **interface_status;
60
64
printf ("Printing ring status.\n");
61
65
result = corosync_cfg_initialize (&handle, NULL);
62
if (result != SA_AIS_OK) {
66
if (result != CS_OK) {
63
67
printf ("Could not initialize corosync configuration API error %d\n", result);
67
corosync_cfg_ring_status_get (handle,
72
for (i = 0; i < interface_count; i++) {
73
printf ("RING ID %d\n", i);
74
printf ("\tid\t= %s\n", interface_names[i]);
75
printf ("\tstatus\t= %s\n", interface_status[i]);
78
corosync_cfg_finalize (handle);
71
result = corosync_cfg_local_get(handle, &nodeid);
72
if (result != CS_OK) {
73
printf ("Could not get the local node id, the error is: %d\n", result);
76
printf ("Local node ID %d\n", nodeid);
79
result = corosync_cfg_ring_status_get (handle,
83
if (result != CS_OK) {
84
printf ("Could not get the ring status, the error is: %d\n", result);
86
for (i = 0; i < interface_count; i++) {
87
printf ("RING ID %d\n", i);
88
printf ("\tid\t= %s\n", interface_names[i]);
89
printf ("\tstatus\t= %s\n", interface_status[i]);
92
(void)corosync_cfg_finalize (handle);
81
95
static void ringreenable_do (void)
84
98
corosync_cfg_handle_t handle;
86
100
printf ("Re-enabling all failed rings.\n");
87
101
result = corosync_cfg_initialize (&handle, NULL);
88
if (result != SA_AIS_OK) {
102
if (result != CS_OK) {
89
103
printf ("Could not initialize corosync configuration API error %d\n", result);
93
107
result = corosync_cfg_ring_reenable (handle);
94
if (result != SA_AIS_OK) {
108
if (result != CS_OK) {
95
109
printf ("Could not reenable ring error %d\n", result);
98
corosync_cfg_finalize (handle);
112
(void)corosync_cfg_finalize (handle);
101
void service_load_do (char *service, unsigned int version)
115
static void service_load_do (const char *service, unsigned int version)
104
118
corosync_cfg_handle_t handle;
106
120
printf ("Loading service '%s' version '%d'\n", service, version);
107
121
result = corosync_cfg_initialize (&handle, NULL);
108
if (result != SA_AIS_OK) {
122
if (result != CS_OK) {
109
123
printf ("Could not initialize corosync configuration API error %d\n", result);
112
126
result = corosync_cfg_service_load (handle, service, version);
113
if (result != SA_AIS_OK) {
127
if (result != CS_OK) {
114
128
printf ("Could not load service (error = %d)\n", result);
116
corosync_cfg_finalize (handle);
130
(void)corosync_cfg_finalize (handle);
119
void service_unload_do (char *service, unsigned int version)
133
static void service_unload_do (const char *service, unsigned int version)
122
136
corosync_cfg_handle_t handle;
124
138
printf ("Unloading service '%s' version '%d'\n", service, version);
125
139
result = corosync_cfg_initialize (&handle, NULL);
126
if (result != SA_AIS_OK) {
140
if (result != CS_OK) {
127
141
printf ("Could not initialize corosync configuration API error %d\n", result);
130
144
result = corosync_cfg_service_unload (handle, service, version);
131
if (result != SA_AIS_OK) {
145
if (result != CS_OK) {
132
146
printf ("Could not unload service (error = %d)\n", result);
134
corosync_cfg_finalize (handle);
139
printf ("corosync-cfgtool [-s] [-r] [-l] [-u] [service_name] [-v] [version]\n\n");
148
(void)corosync_cfg_finalize (handle);
151
static void shutdown_do(void)
154
corosync_cfg_handle_t handle;
155
corosync_cfg_callbacks_t callbacks;
157
callbacks.corosync_cfg_shutdown_callback = NULL;
159
result = corosync_cfg_initialize (&handle, &callbacks);
160
if (result != CS_OK) {
161
printf ("Could not initialize corosync configuration API error %d\n", result);
165
printf ("Shutting down corosync\n");
166
result = corosync_cfg_try_shutdown (handle, COROSYNC_CFG_SHUTDOWN_FLAG_REQUEST);
167
if (result != CS_OK) {
168
printf ("Could not shutdown (error = %d)\n", result);
171
(void)corosync_cfg_finalize (handle);
174
static void showaddrs_do(int nodeid)
177
corosync_cfg_handle_t handle;
178
corosync_cfg_callbacks_t callbacks;
181
corosync_cfg_node_address_t addrs[INTERFACE_MAX];
184
result = corosync_cfg_initialize (&handle, &callbacks);
185
if (result != CS_OK) {
186
printf ("Could not initialize corosync configuration API error %d\n", result);
190
if (corosync_cfg_get_node_addrs(handle, nodeid, INTERFACE_MAX, &numaddrs, addrs) == CS_OK) {
191
for (i=0; i<numaddrs; i++) {
192
char buf[INET6_ADDRSTRLEN];
193
struct sockaddr_storage *ss = (struct sockaddr_storage *)addrs[i].address;
194
struct sockaddr_in *sin = (struct sockaddr_in *)addrs[i].address;
195
struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)addrs[i].address;
198
if (ss->ss_family == AF_INET6)
199
saddr = &sin6->sin6_addr;
201
saddr = &sin->sin_addr;
203
inet_ntop(ss->ss_family, saddr, buf, sizeof(buf));
210
(void)corosync_cfg_finalize (handle);
214
static void crypto_do(unsigned int type)
217
corosync_cfg_handle_t handle;
219
printf ("Setting crypto to mode %d\n", type);
220
result = corosync_cfg_initialize (&handle, NULL);
221
if (result != CS_OK) {
222
printf ("Could not initialize corosync configuration API error %d\n", result);
225
result = corosync_cfg_crypto_set (handle, type);
226
if (result != CS_OK) {
227
printf ("Could not set crypto mode (error = %d)\n", result);
229
(void)corosync_cfg_finalize (handle);
233
static void killnode_do(unsigned int nodeid)
236
corosync_cfg_handle_t handle;
238
printf ("Killing node %d\n", nodeid);
239
result = corosync_cfg_initialize (&handle, NULL);
240
if (result != CS_OK) {
241
printf ("Could not initialize corosync configuration API error %d\n", result);
244
result = corosync_cfg_kill_node (handle, nodeid, "Killed by corosync-cfgtool");
245
if (result != CS_OK) {
246
printf ("Could not kill node (error = %d)\n", result);
248
(void)corosync_cfg_finalize (handle);
252
static void usage_do (void)
254
printf ("corosync-cfgtool [-s] [-r] [-l] [-u] [-H] [service_name] [-v] [version] [-k] [nodeid] [-a] [nodeid]\n\n");
140
255
printf ("A tool for displaying and configuring active parameters within corosync.\n");
141
256
printf ("options:\n");
142
257
printf ("\t-s\tDisplays the status of the current rings on this node.\n");