-
Notifications
You must be signed in to change notification settings - Fork 291
/
ddb_commands.go
300 lines (297 loc) · 8.96 KB
/
ddb_commands.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
//
// (C) Copyright 2022-2023 Intel Corporation.
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
package main
import (
"github.com/desertbit/grumble"
)
func addAppCommands(app *grumble.App, ctx *DdbContext) {
// Command: ls
app.AddCommand(&grumble.Command{
Name: "ls",
Aliases: nil,
Help: "List containers, objects, dkeys, akeys, and values",
LongHelp: "",
HelpGroup: "vos",
Flags: func(f *grumble.Flags) {
f.Bool("r", "recursive", false, "Recursively list the contents of the path")
f.Bool("d", "details", false, "List more details of items in path")
},
Args: func(a *grumble.Args) {
a.String("path", "Optional, list contents of the provided path", grumble.Default(""))
},
Run: func(c *grumble.Context) error {
return ddbLs(ctx, c.Args.String("path"), c.Flags.Bool("recursive"), c.Flags.Bool("details"))
},
Completer: nil,
})
// Command: open
app.AddCommand(&grumble.Command{
Name: "open",
Aliases: nil,
Help: "Opens the vos file at <path>",
LongHelp: `Opens the vos file at <path>. The '-w' option allows for modifying the vos file
with the rm, load, commit_ilog, etc commands. The path <path> should be an absolute path to the
pool shard. Part of the path is used to determine what the pool uuid is.`,
HelpGroup: "vos",
Flags: func(f *grumble.Flags) {
f.Bool("w", "write_mode", false, "Open the vos file in write mode.")
},
Args: func(a *grumble.Args) {
a.String("path", "Path to the vos file to open.")
},
Run: func(c *grumble.Context) error {
return ddbOpen(ctx, c.Args.String("path"), c.Flags.Bool("write_mode"))
},
Completer: openCompleter,
})
// Command: version
app.AddCommand(&grumble.Command{
Name: "version",
Aliases: nil,
Help: "Print ddb version",
LongHelp: "",
HelpGroup: "",
Run: func(c *grumble.Context) error {
return ddbVersion(ctx)
},
Completer: nil,
})
// Command: close
app.AddCommand(&grumble.Command{
Name: "close",
Aliases: nil,
Help: "Close the currently opened vos pool shard",
LongHelp: "",
HelpGroup: "vos",
Run: func(c *grumble.Context) error {
return ddbClose(ctx)
},
Completer: nil,
})
// Command: superblock_dump
app.AddCommand(&grumble.Command{
Name: "superblock_dump",
Aliases: nil,
Help: "Dump the pool superblock information",
LongHelp: "",
HelpGroup: "vos",
Run: func(c *grumble.Context) error {
return ddbSuperblockDump(ctx)
},
Completer: nil,
})
// Command: value_dump
app.AddCommand(&grumble.Command{
Name: "value_dump",
Aliases: nil,
Help: "Dump a value",
LongHelp: `Dump a value to the screen or file. The vos path should be a complete
path, including the akey and if the value is an array value it should include
the extent. If a path to a file was provided then the value will be written to
the file, else it will be printed to the screen.`,
HelpGroup: "vos",
Args: func(a *grumble.Args) {
a.String("path", "VOS tree path to dump.")
a.String("dst", "File path to dump the value to.", grumble.Default(""))
},
Run: func(c *grumble.Context) error {
return ddbValueDump(ctx, c.Args.String("path"), c.Args.String("dst"))
},
Completer: nil,
})
// Command: rm
app.AddCommand(&grumble.Command{
Name: "rm",
Aliases: nil,
Help: "Remove a branch of the VOS tree.",
LongHelp: `Remove a branch of the VOS tree. The branch can be anything from a container
and everything under it, to a single value.`,
HelpGroup: "vos",
Args: func(a *grumble.Args) {
a.String("path", "VOS tree path to remove.")
},
Run: func(c *grumble.Context) error {
return ddbRm(ctx, c.Args.String("path"))
},
Completer: nil,
})
// Command: value_load
app.AddCommand(&grumble.Command{
Name: "value_load",
Aliases: nil,
Help: "Load a value to a vos path. ",
LongHelp: `Load a value to a vos path. This can be used to update
the value of an existing key, or create a new key. The <src> is a path to a
file on the file system. The <dst> is a vos tree path to a value where the
data will be loaded. If the <dst> path currently exists, then the destination
path must match the value type, meaning, if the value type is an array, then
the path must include the extent, otherwise, it must not.`,
HelpGroup: "vos",
Args: func(a *grumble.Args) {
a.String("src", "Source file path.")
a.String("dst", "Destination vos tree path to a value.")
},
Run: func(c *grumble.Context) error {
return ddbValueLoad(ctx, c.Args.String("src"), c.Args.String("dst"))
},
Completer: nil,
})
// Command: ilog_dump
app.AddCommand(&grumble.Command{
Name: "ilog_dump",
Aliases: nil,
Help: "Dump the ilog",
LongHelp: "",
HelpGroup: "vos",
Args: func(a *grumble.Args) {
a.String("path", "VOS tree path to an object, dkey, or akey.")
},
Run: func(c *grumble.Context) error {
return ddbIlogDump(ctx, c.Args.String("path"))
},
Completer: nil,
})
// Command: ilog_commit
app.AddCommand(&grumble.Command{
Name: "ilog_commit",
Aliases: nil,
Help: "Process the ilog",
LongHelp: "",
HelpGroup: "vos",
Args: func(a *grumble.Args) {
a.String("path", "VOS tree path to an object, dkey, or akey.")
},
Run: func(c *grumble.Context) error {
return ddbIlogCommit(ctx, c.Args.String("path"))
},
Completer: nil,
})
// Command: ilog_clear
app.AddCommand(&grumble.Command{
Name: "ilog_clear",
Aliases: nil,
Help: "Remove all the ilog entries",
LongHelp: "",
HelpGroup: "vos",
Args: func(a *grumble.Args) {
a.String("path", "VOS tree path to an object, dkey, or akey.")
},
Run: func(c *grumble.Context) error {
return ddbIlogClear(ctx, c.Args.String("path"))
},
Completer: nil,
})
// Command: dtx_dump
app.AddCommand(&grumble.Command{
Name: "dtx_dump",
Aliases: nil,
Help: "Dump the dtx tables",
LongHelp: "",
HelpGroup: "vos",
Flags: func(f *grumble.Flags) {
f.Bool("a", "active", false, "Only dump entries from the active table")
f.Bool("c", "committed", false, "Only dump entries from the committed table")
},
Args: func(a *grumble.Args) {
a.String("path", "VOS tree path to a container.")
},
Run: func(c *grumble.Context) error {
return ddbDtxDump(ctx, c.Args.String("path"), c.Flags.Bool("active"), c.Flags.Bool("committed"))
},
Completer: nil,
})
// Command: dtx_cmt_clear
app.AddCommand(&grumble.Command{
Name: "dtx_cmt_clear",
Aliases: nil,
Help: "Clear the dtx committed table",
LongHelp: "",
HelpGroup: "vos",
Args: func(a *grumble.Args) {
a.String("path", "VOS tree path to a container.")
},
Run: func(c *grumble.Context) error {
return ddbDtxCmtClear(ctx, c.Args.String("path"))
},
Completer: nil,
})
// Command: smd_sync
app.AddCommand(&grumble.Command{
Name: "smd_sync",
Aliases: nil,
Help: "Restore the SMD file with backup from blob",
LongHelp: "",
HelpGroup: "smd",
Args: func(a *grumble.Args) {
a.String("nvme_conf", "Path to the nvme conf file. (default /mnt/daos/daos_nvme.conf)", grumble.Default(""))
a.String("db_path", "Path to the vos db. (default /mnt/daos)", grumble.Default(""))
},
Run: func(c *grumble.Context) error {
return ddbSmdSync(ctx, c.Args.String("nvme_conf"), c.Args.String("db_path"))
},
Completer: nil,
})
// Command: vea_dump
app.AddCommand(&grumble.Command{
Name: "vea_dump",
Aliases: nil,
Help: "Dump information from the vea about free regions",
LongHelp: "",
HelpGroup: "vos",
Run: func(c *grumble.Context) error {
return ddbVeaDump(ctx)
},
Completer: nil,
})
// Command: vea_update
app.AddCommand(&grumble.Command{
Name: "vea_update",
Aliases: nil,
Help: "Alter the VEA tree to mark a region as free.",
LongHelp: "",
HelpGroup: "vos",
Args: func(a *grumble.Args) {
a.String("offset", "Block offset of the region to mark free.")
a.String("blk_cnt", "Total blocks of the region to mark free.")
},
Run: func(c *grumble.Context) error {
return ddbVeaUpdate(ctx, c.Args.String("offset"), c.Args.String("blk_cnt"))
},
Completer: nil,
})
// Command: dtx_act_commit
app.AddCommand(&grumble.Command{
Name: "dtx_act_commit",
Aliases: nil,
Help: "Mark the active dtx entry as committed",
LongHelp: "",
HelpGroup: "vos",
Args: func(a *grumble.Args) {
a.String("path", "VOS tree path to a container.")
a.String("dtx_id", "DTX id of the entry to commit. ")
},
Run: func(c *grumble.Context) error {
return ddbDtxActCommit(ctx, c.Args.String("path"), c.Args.String("dtx_id"))
},
Completer: nil,
})
// Command: dtx_act_abort
app.AddCommand(&grumble.Command{
Name: "dtx_act_abort",
Aliases: nil,
Help: "Mark the active dtx entry as aborted",
LongHelp: "",
HelpGroup: "vos",
Args: func(a *grumble.Args) {
a.String("path", "VOS tree path to a container.")
a.String("dtx_id", "DTX id of the entry to abort. ")
},
Run: func(c *grumble.Context) error {
return ddbDtxActAbort(ctx, c.Args.String("path"), c.Args.String("dtx_id"))
},
Completer: nil,
})
}