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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016 Red Hat, Inc. <http://www.redhat.com>
# This file is part of GlusterFS.
#
# This file is licensed to you under your choice of the GNU Lesser
# General Public License, version 3 or any later version (LGPLv3 or
# later), or the GNU General Public License, version 2 (GPLv2), in all
# cases as published by the Free Software Foundation.
#
import os
import sys
GLUSTER_SRC_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
eventtypes_h = os.path.join(GLUSTER_SRC_ROOT, "libglusterfs/src/eventtypes.h")
eventtypes_py = os.path.join(GLUSTER_SRC_ROOT, "events/src/eventtypes.py")
gen_header_type = sys.argv[1]
# When adding new keys add it to the END
keys = (
# user driven events
#peer and volume management events
"EVENT_PEER_ATTACH",
"EVENT_PEER_DETACH",
"EVENT_VOLUME_CREATE",
"EVENT_VOLUME_START",
"EVENT_VOLUME_STOP",
"EVENT_VOLUME_DELETE",
"EVENT_VOLUME_SET",
"EVENT_VOLUME_RESET",
"EVENT_BRICK_RESET_START",
"EVENT_BRICK_RESET_COMMIT",
"EVENT_BRICK_REPLACE",
#geo-rep events
"EVENT_GEOREP_CREATE",
"EVENT_GEOREP_START",
"EVENT_GEOREP_STOP",
"EVENT_GEOREP_PAUSE",
"EVENT_GEOREP_RESUME",
"EVENT_GEOREP_DELETE",
"EVENT_GEOREP_CONFIG_SET",
"EVENT_GEOREP_CONFIG_RESET",
#bitrot events
"EVENT_BITROT_ENABLE",
"EVENT_BITROT_DISABLE",
"EVENT_BITROT_SCRUB_THROTTLE",
"EVENT_BITROT_SCRUB_FREQ",
"EVENT_BITROT_SCRUB_OPTION",
"EVENT_BITROT_SCRUB_ONDEMAND",
#quota events
"EVENT_QUOTA_ENABLE",
"EVENT_QUOTA_DISABLE",
"EVENT_QUOTA_SET_USAGE_LIMIT",
"EVENT_QUOTA_SET_OBJECTS_LIMIT",
"EVENT_QUOTA_REMOVE_USAGE_LIMIT",
"EVENT_QUOTA_REMOVE_OBJECTS_LIMIT",
"EVENT_QUOTA_ALERT_TIME",
"EVENT_QUOTA_SOFT_TIMEOUT",
"EVENT_QUOTA_HARD_TIMEOUT",
"EVENT_QUOTA_DEFAULT_SOFT_LIMIT",
#snapshot events
"EVENT_SNAPSHOT_CREATED",
"EVENT_SNAPSHOT_CREATE_FAILED",
"EVENT_SNAPSHOT_ACTIVATED",
"EVENT_SNAPSHOT_ACTIVATE_FAILED",
"EVENT_SNAPSHOT_DEACTIVATED",
"EVENT_SNAPSHOT_DEACTIVATE_FAILED",
"EVENT_SNAPSHOT_SOFT_LIMIT_REACHED",
"EVENT_SNAPSHOT_HARD_LIMIT_REACHED",
"EVENT_SNAPSHOT_RESTORED",
"EVENT_SNAPSHOT_RESTORE_FAILED",
"EVENT_SNAPSHOT_DELETED",
"EVENT_SNAPSHOT_DELETE_FAILED",
"EVENT_SNAPSHOT_CLONED",
"EVENT_SNAPSHOT_CLONE_FAILED",
"EVENT_SNAPSHOT_CONFIG_UPDATED",
"EVENT_SNAPSHOT_CONFIG_UPDATE_FAILED",
"EVENT_SNAPSHOT_SCHEDULER_INITIALISED",
"EVENT_SNAPSHOT_SCHEDULER_INIT_FAILED",
"EVENT_SNAPSHOT_SCHEDULER_ENABLED",
"EVENT_SNAPSHOT_SCHEDULER_ENABLE_FAILED",
"EVENT_SNAPSHOT_SCHEDULER_DISABLED",
"EVENT_SNAPSHOT_SCHEDULER_DISABLE_FAILED",
"EVENT_SNAPSHOT_SCHEDULER_SCHEDULE_ADDED",
"EVENT_SNAPSHOT_SCHEDULER_SCHEDULE_ADD_FAILED",
"EVENT_SNAPSHOT_SCHEDULER_SCHEDULE_EDITED",
"EVENT_SNAPSHOT_SCHEDULER_SCHEDULE_EDIT_FAILED",
"EVENT_SNAPSHOT_SCHEDULER_SCHEDULE_DELETED",
"EVENT_SNAPSHOT_SCHEDULER_SCHEDULE_DELETE_FAILED",
#async events
#glusterd events
"EVENT_SVC_MANAGER_FAILED",
"EVENT_SVC_RECONFIGURE_FAILED",
"EVENT_SVC_CONNECTED",
"EVENT_SVC_DISCONNECTED",
"EVENT_PEER_STORE_FAILURE",
"EVENT_PEER_RPC_CREATE_FAILED",
"EVENT_PEER_REJECT",
"EVENT_PEER_CONNECT",
"EVENT_PEER_DISCONNECT",
"EVENT_PEER_NOT_FOUND",
"EVENT_UNKNOWN_PEER",
"EVENT_BRICK_START_FAILED",
"EVENT_BRICK_STOP_FAILED",
"EVENT_BRICK_DISCONNECTED",
"EVENT_BRICK_CONNECTED",
"EVENT_BRICKPATH_RESOLVE_FAILED",
"EVENT_NOTIFY_UNKNOWN_OP",
"EVENT_QUORUM_LOST",
"EVENT_QUORUM_REGAINED",
"EVENT_REBALANCE_START_FAILED",
"EVENT_REBALANCE_STATUS_UPDATE_FAILED",
"EVENT_IMPORT_QUOTA_CONF_FAILED",
"EVENT_IMPORT_VOLUME_FAILED",
"EVENT_IMPORT_BRICK_FAILED",
"EVENT_COMPARE_FRIEND_VOLUME_FAILED",
"EVENT_NFS_GANESHA_EXPORT_FAILED",
#ec events
"EVENT_EC_MIN_BRICKS_NOT_UP",
"EVENT_EC_MIN_BRICKS_UP",
#georep async events
"EVENT_GEOREP_FAULTY",
"EVENT_GEOREP_CHECKPOINT_COMPLETED",
"EVENT_GEOREP_ACTIVE",
"EVENT_GEOREP_PASSIVE",
#quota async events
"EVENT_QUOTA_CROSSED_SOFT_LIMIT",
#bitrot async events
"EVENT_BITROT_BAD_FILE",
#protocol-server events
"EVENT_CLIENT_CONNECT",
"EVENT_CLIENT_AUTH_REJECT",
"EVENT_CLIENT_DISCONNECT",
#posix events
"EVENT_POSIX_SAME_GFID",
"EVENT_POSIX_ALREADY_PART_OF_VOLUME",
"EVENT_POSIX_BRICK_NOT_IN_VOLUME",
"EVENT_POSIX_BRICK_VERIFICATION_FAILED",
"EVENT_POSIX_ACL_NOT_SUPPORTED",
"EVENT_POSIX_HEALTH_CHECK_FAILED",
#afr events
"EVENT_AFR_QUORUM_MET",
"EVENT_AFR_QUORUM_FAIL",
"EVENT_AFR_SUBVOL_UP",
"EVENT_AFR_SUBVOLS_DOWN",
"EVENT_AFR_SPLIT_BRAIN",
#tier events
"EVENT_TIER_ATTACH",
"EVENT_TIER_ATTACH_FORCE",
"EVENT_TIER_DETACH_START",
"EVENT_TIER_DETACH_STOP",
"EVENT_TIER_DETACH_COMMIT",
"EVENT_TIER_DETACH_FORCE",
"EVENT_TIER_PAUSE",
"EVENT_TIER_RESUME",
"EVENT_TIER_WATERMARK_HI",
"EVENT_TIER_WATERMARK_DROPPED_TO_MID",
"EVENT_TIER_WATERMARK_RAISED_TO_MID",
"EVENT_TIER_WATERMARK_DROPPED_TO_LOW",
#dht events
#add/remove brick events
"EVENT_VOLUME_ADD_BRICK",
"EVENT_VOLUME_ADD_BRICK_FAILED",
"EVENT_VOLUME_REMOVE_BRICK_START",
"EVENT_VOLUME_REMOVE_BRICK_START_FAILED",
"EVENT_VOLUME_REMOVE_BRICK_COMMIT",
"EVENT_VOLUME_REMOVE_BRICK_COMMIT_FAILED",
"EVENT_VOLUME_REMOVE_BRICK_STOP",
"EVENT_VOLUME_REMOVE_BRICK_STOP_FAILED",
"EVENT_VOLUME_REMOVE_BRICK_FORCE",
"EVENT_VOLUME_REMOVE_BRICK_FORCE_FAILED",
"EVENT_VOLUME_REMOVE_BRICK_FAILED",
#rebalance events
"EVENT_VOLUME_REBALANCE_START",
"EVENT_VOLUME_REBALANCE_STOP",
"EVENT_VOLUME_REBALANCE_FAILED",
"EVENT_VOLUME_REBALANCE_COMPLETE",
#tier events
"EVENT_TIER_START",
"EVENT_TIER_START_FORCE",
#brick/inodes events
"EVENT_DHT_DISK_USAGE",
"EVENT_DHT_INODES_USAGE",
)
LAST_EVENT = "EVENT_LAST"
ERRORS = (
"EVENT_SEND_OK",
"EVENT_ERROR_INVALID_INPUTS",
"EVENT_ERROR_SOCKET",
"EVENT_ERROR_CONNECT",
"EVENT_ERROR_SEND",
"EVENT_ERROR_RESOLVE",
"EVENT_ERROR_MSG_FORMAT",
)
if gen_header_type == "C_HEADER":
# Generate eventtypes.h
with open(eventtypes_h, "w") as f:
f.write("#ifndef __EVENTTYPES_H__\n")
f.write("#define __EVENTTYPES_H__\n\n")
f.write("typedef enum {\n")
for k in ERRORS:
f.write(" {0},\n".format(k))
f.write("} event_errors_t;\n")
f.write("\n")
f.write("typedef enum {\n")
for k in keys:
f.write(" {0},\n".format(k))
f.write(" {0}\n".format(LAST_EVENT))
f.write("} eventtypes_t;\n")
f.write("\n#endif /* __EVENTTYPES_H__ */\n")
if gen_header_type == "PY_HEADER":
# Generate eventtypes.py
with open(eventtypes_py, "w") as f:
f.write("# -*- coding: utf-8 -*-\n")
f.write("all_events = [\n")
for ev in keys:
f.write(' "{0}",\n'.format(ev))
f.write("]\n\n")
for idx, ev in enumerate(keys):
f.write("{0} = {1}\n".format(ev.replace("EVENT_", ""), idx))
|