Compare commits

..

1 Commits

Author SHA1 Message Date
9cd3db68b5 Print vitastor-cli help for ls-osds and user-modify aliases
vitastor-cli accepts ls-osds and user-modify, but --help does not list
them, so "vitastor-cli --help ls-osds" printed "Unknown command". Add
them to the help and to the docs, which also lacked the pgs alias in the
Russian version. Test that --help knows every name the CLI accepts.
2026-10-25 16:10:29 +03:00
7 changed files with 24 additions and 51 deletions

View File

@@ -355,7 +355,7 @@ host stump
## ls-osd
`vitastor-cli osds|ls-osd|osd-ls [-l|--long]`
`vitastor-cli osds|ls-osds|ls-osd|osd-ls [-l|--long]`
Show current OSDs as list, optionally with I/O statistics if -l is specified.
@@ -508,7 +508,7 @@ the Vitastor authorization model.
## modify-user
`vitastor-cli modify-user --groups <group1,group2,...> <username>`
`vitastor-cli modify-user|user-modify --groups <group1,group2,...> <username>`
Create or update a user with the given name (matching TLS certificate CN).

View File

@@ -373,7 +373,7 @@ host stump
## ls-osd
`vitastor-cli osds|ls-osd|osd-ls [-l|--long]`
`vitastor-cli osds|ls-osds|ls-osd|osd-ls [-l|--long]`
Показать список OSD, со статистикой ввода-вывода, если установлено -l.
@@ -403,7 +403,7 @@ OSD PARENT UP SIZE USED% TAGS WEIGHT BLOCK BITMAP
## pg-list
`vitastor-cli pg-list|pg-ls|list-pg|ls-pg|ls-pgs [OPTIONS] [state1+state2] [^state3] [...]`
`vitastor-cli pg-list|pg-ls|list-pg|ls-pg|ls-pgs|pgs [OPTIONS] [state1+state2] [^state3] [...]`
Вывести список PG с состояними, удовлетворяющими любому из переданных фильтров (^ или !
в начале фильтра означает отрицание). Опции:
@@ -527,7 +527,7 @@ OSD PARENT UP SIZE USED% TAGS WEIGHT BLOCK BITMAP
## modify-user
`vitastor-cli modify-user --groups <group1,group2,...> <username>`
`vitastor-cli modify-user|user-modify --groups <group1,group2,...> <username>`
Создать или изменить пользователя с указанным именем (совпадающим с CN TLS-сертификата).

View File

@@ -179,7 +179,7 @@ static const char* help_text =
"vitastor-cli osd-tree [-l|--long]\n"
" Show current OSD tree, optionally with I/O statistics if -l is specified.\n"
"\n"
"vitastor-cli osds|ls-osd|osd-ls [-l|--long]\n"
"vitastor-cli osds|ls-osds|ls-osd|osd-ls [-l|--long]\n"
" Show current OSDs as list, optionally with I/O statistics if -l is specified.\n"
"\n"
"vitastor-cli modify-osd [--tags tag1,tag2,...] [--reweight <number>] [--noout true/false] <osd_number>\n"
@@ -253,7 +253,7 @@ static const char* help_text =
"vitastor-cli ls-users|user-ls|ls-user|list-users [<name> ...]\n"
" List users (only with specified names if passed).\n"
"\n"
"vitastor-cli modify-user --type <type> --groups group1,group2,... <username>\n"
"vitastor-cli modify-user|user-modify --type <type> --groups group1,group2,... <username>\n"
" Create or update user permissions. User names match CN of their certificates.\n"
" --type TYPE Set user type: client or admin. Default is client.\n"
" --groups GROUPS Set user's groups.\n"

View File

@@ -287,20 +287,7 @@ std::function<bool(cli_result_t &)> cli_tool_t::start_modify(json11::Json cfg)
changer->parent = this;
changer->image_name = cfg["image"].string_value();
changer->new_name = cfg["rename"].string_value();
if (!cfg["resize"].is_null())
{
bool ok = false;
changer->new_size = parse_size(cfg["resize"].as_string(), &ok);
if (!ok)
{
delete changer;
return [size = cfg["resize"].as_string()](cli_result_t & result)
{
result = (cli_result_t){ .err = EINVAL, .text = "Invalid syntax for size: "+size };
return true;
};
}
}
changer->new_size = parse_size(cfg["resize"].as_string());
changer->force_size = cfg["force_size"].bool_value();
changer->inc_size = cfg["inc_size"].bool_value();
changer->force = cfg["force"].bool_value();

View File

@@ -64,8 +64,6 @@ OLD=1 ./test_move_reappear.sh
./test_rm.sh
./test_modify_image_resize.sh
./test_rm_degraded.sh
./test_snapshot_chain.sh
@@ -97,6 +95,8 @@ OLD=1 SCHEME=ec IMMEDIATE_COMMIT=1 ./test_rebalance_verify.sh
./test_dd.sh
./test_cli_help.sh
./test_root_node.sh
./test_switch_primary.sh

14
tests/test_cli_help.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash -ex
# Test that vitastor-cli --help knows every command name and alias the CLI accepts
. `dirname $0`/common.sh
for cmd in $(grep -o 'cmd\[0\] == "[^"]*"' src/cmd/cli.cpp | sed 's/.*== "//; s/"$//'); do
build/src/cmd/vitastor-cli --help $cmd > ./testdata/help.txt 2>&1 || true
if grep -q '^Unknown command' ./testdata/help.txt; then
format_error "vitastor-cli --help $cmd does not know the command"
fi
done
format_green OK

View File

@@ -1,28 +0,0 @@
#!/bin/bash -ex
# Test that modify refuses an invalid --resize value instead of ignoring it
. `dirname $0`/common.sh
wait_etcd
$ETCDCTL put /vitastor/config/pools '{"1":{"name":"testpool","scheme":"replicated","pg_size":2,"pg_minsize":1,"pg_count":1,"failure_domain":"osd"}}'
$VITASTOR_CLI create -s 1G --pool testpool testimg
for size in 1.5G 10X abc ''; do
r=0
$VITASTOR_CLI modify testimg --resize "$size" || r=$?
if [[ $r != 22 ]]; then
format_error "modify --resize '$size' should fail with EINVAL (22), but exited with $r"
fi
done
$ETCDCTL get --print-value-only /vitastor/config/inode/1/1 | jq -e '.size == 1073741824' || \
format_error "Image size should stay 1G after refused resizes"
$VITASTOR_CLI modify testimg --resize 2G
$ETCDCTL get --print-value-only /vitastor/config/inode/1/1 | jq -e '.size == 2147483648' || \
format_error "Image size should be 2G after --resize 2G"
format_green OK