vitastor-disk: pass config_path to vitastor-cli/vitastor-osd #138

Merged
vitalif merged 1 commits from lei.xianqiang/vitastor:pass_config_path into master 2026-11-20 18:52:35 +03:00
3 changed files with 28 additions and 3 deletions

View File

@@ -65,6 +65,7 @@ static const char *help_text =
" --force Bypass partition safety checks (for emptiness and so on)\n"
" \n"
" Options (both modes):\n"
" --config_path <FILE> Path to Vitastor configuration file\n"
" --tags tag1,tag2 Set new OSD tag(s)\n"
" --weight <number> Set new OSD weight (between 0 and 1)\n"
" --journal_size 32M/1G Set journal size (area or partition size)\n"

View File

@@ -239,10 +239,19 @@ int disk_tool_t::prepare_one(std::map<std::string, std::string> options, int is_
{
osd_num_str = options["osd_num"];
}
else if (shell_exec({ "vitastor-cli", "alloc-osd" }, "", &osd_num_str, NULL) != 0)
else
{
dsk.close_all();
return 1;
std::vector<std::string> cmd = { "vitastor-cli", "alloc-osd" };
if (options.find("config_path") != options.end())
{
cmd.push_back("--config_path");
cmd.push_back(options["config_path"]);
}
if (shell_exec(cmd, "", &osd_num_str, NULL) != 0)
{
dsk.close_all();
return 1;
}
}
osd_num_t osd_num = stoull_full(trim(osd_num_str), 10);
if (!osd_num)
@@ -255,6 +264,11 @@ int disk_tool_t::prepare_one(std::map<std::string, std::string> options, int is_
if (options.find("weight") != options.end() || options.find("tags") != options.end())
{
std::vector<std::string> cmd = { "vitastor-cli", "modify-osd", std::to_string(osd_num) };
if (options.find("config_path") != options.end())
{
cmd.push_back("--config_path");
cmd.push_back(options["config_path"]);
}
if (options.find("weight") != options.end())
{
cmd.push_back("--reweight");

View File

@@ -324,6 +324,11 @@ int disk_tool_t::exec_osd(std::string device)
argstr.push_back("--"+kv.first);
argstr.push_back(kv.second.is_string() ? kv.second.string_value() : kv.second.dump());
}
if (options.find("config_path") != options.end())
{
argstr.push_back("--config_path");
argstr.push_back(options["config_path"]);
}
char *argv[argstr.size()+1];
for (int i = 0; i < argstr.size(); i++)
{
@@ -453,6 +458,11 @@ int disk_tool_t::purge_devices(const std::vector<std::string> & devices)
return 0;
}
std::vector<std::string> rm_osd_cli = { "vitastor-cli", "rm-osd", "--allow-up" };
if (options.find("config_path") != options.end())
{
rm_osd_cli.push_back("--config_path");
rm_osd_cli.push_back(options["config_path"]);
}
for (auto osd_num: osd_numbers)
{
rm_osd_cli.push_back(std::to_string(osd_num));