Rename commands and add CLI help
parent
4319091bd3
commit
d5efbbb6b9
46
src/cli.cpp
46
src/cli.cpp
|
@ -43,7 +43,7 @@ json11::Json::object cli_tool_t::parse_args(int narg, const char *args[])
|
|||
std::string exe(exe_name);
|
||||
if (exe.substr(exe.size()-11) == "vitastor-rm")
|
||||
{
|
||||
cmd.push_back("rm");
|
||||
cmd.push_back("rm-data");
|
||||
}
|
||||
}
|
||||
cfg["command"] = cmd;
|
||||
|
@ -53,14 +53,36 @@ json11::Json::object cli_tool_t::parse_args(int narg, const char *args[])
|
|||
void cli_tool_t::help()
|
||||
{
|
||||
printf(
|
||||
"Vitastor inode removal tool\n"
|
||||
"(c) Vitaliy Filippov, 2020 (VNPL-1.1)\n\n"
|
||||
"Vitastor command-line tool\n"
|
||||
"(c) Vitaliy Filippov, 2019+ (VNPL-1.1)\n\n"
|
||||
"USAGE:\n"
|
||||
" %s rm [--etcd_address <etcd_address>] --pool <pool> --inode <inode>\n"
|
||||
" [--wait-list] [--iodepth 32] [--parallel_osds 4] [--progress 1]\n"
|
||||
" %s merge [--etcd_address <etcd_address>] <from> <to> [--target <from>]\n"
|
||||
" [--iodepth 128] [--progress 1] [--cas 0|1]\n",
|
||||
exe_name, exe_name
|
||||
"%s rm-data [OPTIONS] --pool <pool> --inode <inode> [--wait-list]\n"
|
||||
" Remove inode data without changing metadata.\n"
|
||||
" --wait-list means first retrieve objects listings and then remove it.\n"
|
||||
" --wait-list requires more memory, but allows to show correct stats.\n"
|
||||
"\n"
|
||||
"%s merge-data [OPTIONS] <from> <to> [--target <target>]\n"
|
||||
" Merge layer data without changing metadata. Merge <from>..<to> to <target>.\n"
|
||||
" <to> must be a child of <from> and <target> may be one of the layers between\n"
|
||||
" <from> and <to>, including <from> and <to>.\n"
|
||||
"\n"
|
||||
"%s flatten [OPTIONS] <layer>\n"
|
||||
" Flatten a layer, i.e. merge data and detach it from parents\n"
|
||||
"\n"
|
||||
"%s rm [OPTIONS] <from> [<to>] [--writers-stopped 1]\n"
|
||||
" Remove <from> or all layers between <from> and <to> (<to> must be a child of <from>),\n"
|
||||
" rebasing all their children accordingly. One of deleted parents may be renamed to one\n"
|
||||
" of children \"to be rebased\", but only if that child itself is readonly or if\n"
|
||||
" --writers-stopped 1 is specified\n"
|
||||
"\n"
|
||||
"OPTIONS (global):\n"
|
||||
" --etcd_address <etcd_address>\n"
|
||||
" --iodepth N Send N operations in parallel to each OSD when possible (default 32)\n"
|
||||
" --parallel_osds M Work with M osds in parallel when possible (default 4)\n"
|
||||
" --progress 1|0 Report progress (default 1)\n"
|
||||
" --cas 1|0 Use online CAS writes when possible (default auto)\n"
|
||||
,
|
||||
exe_name, exe_name, exe_name, exe_name
|
||||
);
|
||||
exit(0);
|
||||
}
|
||||
|
@ -166,12 +188,12 @@ void cli_tool_t::run(json11::Json cfg)
|
|||
fprintf(stderr, "command is missing\n");
|
||||
exit(1);
|
||||
}
|
||||
else if (cmd[0] == "rm")
|
||||
else if (cmd[0] == "rm-data")
|
||||
{
|
||||
// Delete inode
|
||||
// Delete inode data
|
||||
action_cb = start_rm(cfg);
|
||||
}
|
||||
else if (cmd[0] == "merge")
|
||||
else if (cmd[0] == "merge-data")
|
||||
{
|
||||
// Merge layer data without affecting metadata
|
||||
action_cb = start_merge(cfg);
|
||||
|
@ -181,7 +203,7 @@ void cli_tool_t::run(json11::Json cfg)
|
|||
// Merge layer data without affecting metadata
|
||||
action_cb = start_flatten(cfg);
|
||||
}
|
||||
else if (cmd[0] == "snap-rm")
|
||||
else if (cmd[0] == "rm")
|
||||
{
|
||||
// Remove multiple snapshots and rebase their children
|
||||
action_cb = start_snap_rm(cfg);
|
||||
|
|
|
@ -67,7 +67,7 @@ struct snap_flattener_t
|
|||
get_merge_parents();
|
||||
// Start merger
|
||||
merger_cb = parent->start_merge(json11::Json::object {
|
||||
{ "command", json11::Json::array{ "merge", top_parent_name, target_name } },
|
||||
{ "command", json11::Json::array{ "merge-data", top_parent_name, target_name } },
|
||||
{ "target", target_name },
|
||||
{ "delete-source", false },
|
||||
{ "cas", use_cas },
|
||||
|
|
|
@ -467,7 +467,7 @@ resume_9:
|
|||
exit(1);
|
||||
}
|
||||
cb = parent->start_merge(json11::Json::object {
|
||||
{ "command", json11::Json::array{ "merge", from_name, child_it->second.name } },
|
||||
{ "command", json11::Json::array{ "merge-data", from_name, child_it->second.name } },
|
||||
{ "target", target_it->second.name },
|
||||
{ "delete-source", false },
|
||||
{ "cas", use_cas },
|
||||
|
|
|
@ -9,6 +9,6 @@ LD_PRELOAD=libasan.so.5 \
|
|||
|
||||
$ETCDCTL get --prefix '/vitastor/pg/state'
|
||||
|
||||
build/src/vitastor-cli rm --etcd_address $ETCD_URL --pool 1 --inode 1
|
||||
build/src/vitastor-cli rm-data --etcd_address $ETCD_URL --pool 1 --inode 1
|
||||
|
||||
format_green OK
|
||||
|
|
|
@ -43,7 +43,7 @@ cmp ./testdata/merged.bin ./testdata/check.bin
|
|||
|
||||
$ETCDCTL put /vitastor/config/inode/1/3 '{"parent_id":2,"name":"testimg","size":'$((32*1024*1024))'}'
|
||||
|
||||
build/src/vitastor-cli snap-rm --etcd_address $ETCD_URL testimg@0
|
||||
build/src/vitastor-cli rm --etcd_address $ETCD_URL testimg@0
|
||||
|
||||
qemu-img convert -S 4096 -p \
|
||||
-f raw "vitastor:etcd_host=127.0.0.1\:$ETCD_PORT/v3:image=testimg" \
|
||||
|
|
Loading…
Reference in New Issue