-
Notifications
You must be signed in to change notification settings - Fork 3
/
bind.go
472 lines (425 loc) · 10.3 KB
/
bind.go
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
/*
* Copyright (c) 2023 NetEase Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Project: Curve-Manager
* Created Date: 2023-02-11
* Author: wanghai (SeanHai)
*/
package manager
import (
"github.com/opencurve/curve-manager/api/curvebs/agent"
"github.com/opencurve/curve-manager/api/curvebs/core"
"github.com/opencurve/pigeon"
)
const (
MODULE = "manager"
)
var METHOD_REQUEST map[string]Request
type (
HandlerFunc func(r *pigeon.Request, ctx *Context) bool
Context struct {
Data interface{}
}
Request struct {
httpMethod string
method string
vType interface{}
handler HandlerFunc
}
)
func init() {
METHOD_REQUEST = map[string]Request{}
for _, request := range requests {
METHOD_REQUEST[request.method] = request
core.BELONG[request.method] = MODULE
}
}
type GetEtcdStatusRequest struct{}
type GetMdsStatusRequest struct{}
type GetSnapShotCloneServerStatusRequest struct{}
type ListTopologyRequest struct{}
type ListLogicalPoolRequest struct{}
type GetLogicalPoolRequest struct {
Id uint32 `json:"id" binding:"required"`
Start uint64 `json:"start" binding:"required"`
End uint64 `json:"end" binding:"required"`
Interval uint64 `json:"interval" binding:"required"`
}
type GetChunkServerStatusRequest struct{}
type GetClusterStatusRequest struct{}
type GetClusterSpaceRequest struct{}
type GetClusterSpaceTrendRequest struct {
Start uint64 `json:"start" binding:"required"`
End uint64 `json:"end" binding:"required"`
Interval uint64 `json:"interval" binding:"required"`
}
type GetClusterPerformanceRequest struct {
Start uint64 `json:"start" binding:"required"`
End uint64 `json:"end" binding:"required"`
Interval uint64 `json:"interval" binding:"required"`
}
type ListHostRequest struct {
Size uint32 `json:"size" binding:"required"`
Page uint32 `json:"page" binding:"required"`
}
type ListVolumeRequest struct {
Size uint32 `json:"size" binding:"required"`
Page uint32 `json:"page" binding:"required"`
Path string `json:"path" default:"/"`
SortKey string `json:"sortKey" default:"id"`
SortDirection int `json:"sortDirection" default:"-1"`
}
type GetVolumeRequest struct {
VolumeName string `json:"volumeName" binding:"required"`
Start uint64 `json:"start" default:"0"`
End uint64 `json:"end" default:"0"`
Interval uint64 `json:"interval" default:"0"`
}
type ListSnapshotRequest struct {
Size uint32 `json:"size" binding:"required"`
Page uint32 `json:"page" binding:"required"`
UUID string `json:"uuid"`
User string `json:"user"`
FileName string `json:"fileName"`
Status string `json:"status"`
}
type GetHostRequest struct {
HostName string `json:"hostName" binding:"required"`
Start uint64 `json:"start" binding:"required"`
End uint64 `json:"end" binding:"required"`
Interval uint64 `json:"interval" binding:"required"`
}
type ListDiskRequest struct {
Size uint32 `json:"size" binding:"required"`
Page uint32 `json:"page" binding:"required"`
HostName string `json:"hostName"`
}
type CleanRecycleBinRequest struct {
Expiration uint64 `json:"expiration" default:"0"`
}
type CreateNameSpaceRequest struct {
Name string `json:"name" binding:"required"`
User string `json:"user" binding:"required"`
PassWord string `json:"password"`
}
type CreateVolumeRequest struct {
VolumeName string `json:"volumeName" binding:"required"`
User string `json:"user" binding:"required"`
Length uint64 `json:"length" binding:"required"`
PassWord string `json:"password"`
StripUnit uint64 `json:"stripUnit"`
StripCount uint64 `json:"stripCount"`
}
type ExtendVolumeRequest struct {
VolumeName string `json:"volumeName" binding:"required"`
Length uint64 `json:"length" binding:"required"`
}
type VolumeThrottleRequest struct {
VolumeName string `json:"volumeName" binding:"required"`
ThrottleType string `json:"throttleType" binding:"required"`
Limit uint64 `json:"limit" binding:"required"`
Burst uint64 `json:"burst"`
BurstLength uint64 `json:"burstLength"`
}
type DeleteVolumeRequest struct {
VolumeNames map[string]string `json:"volumeNames" binding:"required"`
Force *bool `json:"force" default:"false"`
}
type RecoverVolumeRequest struct {
VolumeIds map[string]uint64 `json:"volumeIds" binding:"required"`
}
type CloneVolumeRequest struct {
Src string `json:"src" binding:"required"`
Dest string `json:"dest" binding:"required"`
User string `json:"user" binding:"required"`
Lazy *bool `json:"lazy" binding:"required"`
}
type CreateSnapshotRequest struct {
VolumeName string `json:"volumeName" binding:"required"`
User string `json:"user" binding:"required"`
SnapshotName string `json:"snapshotName" binding:"required"`
}
type CancelSnapshotRequest struct {
Snapshots []agent.Snapshot `json:"snapshots" binding:"required"`
}
type DeleteSnapshotRequest struct {
FileName string `json:"fileName"`
User string `json:"user"`
UUIDs []string `json:"uuids"`
Failed bool `json:"failed" default:"false"`
}
type FlattenRequest struct {
VolumeName string `json:"volumeName" binding:"required"`
User string `json:"user" binding:"required"`
}
type GetSysLogRequest struct {
Start int64 `json:"start" default:"0"`
End int64 `json:"end" default:"0"`
Page uint32 `json:"page" binding:"required"`
Size uint32 `json:"size" binding:"required"`
Filter string `json:"filter"`
}
type GetSysAlertRequest struct {
Start int64 `json:"start" default:"0"`
End int64 `json:"end" default:"0"`
Page uint32 `json:"page" binding:"required"`
Size uint32 `json:"size" binding:"required"`
Name string `json:"name"`
Level string `json:"level"`
Content string `json:"content"`
}
type GetUnreadSysAlertNumRequest struct{}
type UpdateReadSysAlertIdRequest struct {
Id int64 `json:"id" binding:"required"`
}
type GetAlertConfRequest struct{}
type UpdateAlertConfRequest struct {
Name string `json:"name" binding:"required"`
Interval uint32 `json:"interval" binding:"required"`
Times uint32 `json:"times" binding:"required"`
Enable *bool `json:"enable" binding:"required"`
Rule string `json:"rule" binding:"required"`
AlertUsers []string `json:"alertUsers" binding:"required"`
}
type GetAlertCandidateRequest struct{}
type UpdateAlertUserRequest struct {
Alert string `json:"alert" binding:"required"`
User []string `json:"user" binding:"required"`
}
var requests = []Request{
{
core.HTTP_GET,
core.STATUS_ETCD,
GetEtcdStatusRequest{},
GetEtcdStatus,
},
{
core.HTTP_GET,
core.STATUS_MDS,
GetMdsStatusRequest{},
GetMdsStatus,
},
{
core.HTTP_GET,
core.STATUS_SNAPSHOTCLONESERVER,
GetSnapShotCloneServerStatusRequest{},
GetSnapShotCloneServerStatus,
},
{
core.HTTP_GET,
core.STATUS_CHUNKSERVER,
GetChunkServerStatusRequest{},
GetChunkServerStatus,
},
{
core.HTTP_GET,
core.STATUS_CLUSTER,
GetClusterStatusRequest{},
GetClusterStatus,
},
{
core.HTTP_GET,
core.SPACE_CLUSTER,
GetClusterSpaceRequest{},
GetClusterSpace,
},
{
core.HTTP_POST,
core.SPACE_TREND_CLUSTER,
GetClusterSpaceTrendRequest{},
GetClusterSpaceTrend,
},
{
core.HTTP_POST,
core.PERFORMANCE_CLUSTER,
GetClusterPerformanceRequest{},
GetClusterPerformance,
},
{
core.HTTP_GET,
core.TOPO_LIST,
ListTopologyRequest{},
ListTopology,
},
{
core.HTTP_GET,
core.TOPO_POOL_LIST,
ListLogicalPoolRequest{},
ListLogicalPool,
},
{
core.HTTP_POST,
core.TOPO_POOL_GET,
GetLogicalPoolRequest{},
GetLogicalPool,
},
{
core.HTTP_POST,
core.VOLUME_LIST,
ListVolumeRequest{},
ListVolume,
},
{
core.HTTP_POST,
core.VOLUME_GET,
GetVolumeRequest{},
GetVolume,
},
{
core.HTTP_POST,
core.SNAPSHOT_LIST,
ListSnapshotRequest{},
ListSnapshot,
},
{
core.HTTP_POST,
core.HOST_LIST,
ListHostRequest{},
ListHost,
},
{
core.HTTP_POST,
core.HOST_GET,
GetHostRequest{},
GetHost,
},
{
core.HTTP_POST,
core.DISK_LIST,
ListDiskRequest{},
ListDisk,
},
{
core.HTTP_POST,
core.CLEAN_RECYCLEBIN,
CleanRecycleBinRequest{},
CleanRecycleBin,
},
{
core.HTTP_POST,
core.CREATE_NAMESPACE,
CreateNameSpaceRequest{},
CreateNameSpace,
},
{
core.HTTP_POST,
core.CREATE_VOLUME,
CreateVolumeRequest{},
CreateVolume,
},
{
core.HTTP_POST,
core.EXTEND_VOLUME,
ExtendVolumeRequest{},
ExtendVolume,
},
{
core.HTTP_POST,
core.VOLUME_THROTTLE,
VolumeThrottleRequest{},
VolumeThrottle,
},
{
core.HTTP_POST,
core.DELETE_VOLUME,
DeleteVolumeRequest{},
DeleteVolume,
},
{
core.HTTP_POST,
core.RECOVER_VOLUME,
RecoverVolumeRequest{},
RecoverVolume,
},
{
core.HTTP_POST,
core.CLONE_VOLUME,
CloneVolumeRequest{},
CloneVolume,
},
{
core.HTTP_POST,
core.CREATE_SNAPSHOT,
CreateSnapshotRequest{},
CreateSnapshot,
},
{
core.HTTP_POST,
core.CANCEL_SNAPSHOT,
CancelSnapshotRequest{},
CancelSnapshot,
},
{
core.HTTP_POST,
core.DELETE_SNAPSHOT,
DeleteSnapshotRequest{},
DeleteSnapshot,
},
{
core.HTTP_POST,
core.FLATTEN,
FlattenRequest{},
Flatten,
},
{
core.HTTP_POST,
core.GET_SYSTEM_LOG,
GetSysLogRequest{},
GetSysLog,
},
{
core.HTTP_POST,
core.GET_SYSTEM_ALERT,
GetSysAlertRequest{},
GetSysAlert,
},
{
core.HTTP_GET,
core.GET_UNREAD_SYSTEM_ALERT_NUM,
GetUnreadSysAlertNumRequest{},
GetUnreadSysAlertNum,
},
{
core.HTTP_POST,
core.UPDATE_READ_SYSTEM_ALERT_ID,
UpdateReadSysAlertIdRequest{},
UpdateReadSysAlertId,
},
{
core.HTTP_GET,
core.GET_ALERT_CONF,
GetAlertConfRequest{},
GetAlertConf,
},
{
core.HTTP_POST,
core.UPDATE_ALERT_CONF,
UpdateAlertConfRequest{},
UpdateAlertConf,
},
{
core.HTTP_GET,
core.GET_ALERT_CANDIDATE,
GetAlertCandidateRequest{},
GetAlertCandidate,
},
{
core.HTTP_POST,
core.UPDATE_ALERT_USER,
UpdateAlertUserRequest{},
UpdateAlertUser,
},
}