Skip to content

Commit

Permalink
rbd: fix get image or snap spec in nbd map
Browse files Browse the repository at this point in the history
root@s222:/ceph-dev/build# rbd nbd map img1
rbd: 'nbd map' command is deprecated, use 'device map -t nbd' instead
rbd: image name was not specified
root@s222:/ceph-dev/build# rbd nbd map -p rbd --image img1
rbd: 'nbd map' command is deprecated, use 'device map -t nbd' instead
rbd: image name was not specified

Signed-off-by: songweibin <[email protected]>
  • Loading branch information
Songweibin committed Feb 22, 2018
1 parent 2545f97 commit 90892fd
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/tools/rbd/action/Nbd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,32 +219,23 @@ int execute_map_deprecated(const po::variables_map &vm_deprecated,

po::options_description options;
options.add_options()
("read-only", po::bool_switch(), "")
("exclusive", po::bool_switch(), "")
("options,o", po::value<std::vector<std::string>>()
->default_value(std::vector<std::string>(), ""), "");

po::variables_map vm;
po::variables_map vm = vm_deprecated;
po::store(po::command_line_parser({}).options(options).run(), vm);

if (vm_deprecated["read-only"].as<bool>()) {
vm.at("read-only").value() = boost::any(true);
}
if (vm_deprecated["exclusive"].as<bool>()) {
vm.at("exclusive").value() = boost::any(true);
}

std::vector<std::string> opts;
if (vm_deprecated.count("device")) {
opts.push_back("device=" + vm_deprecated["device"].as<std::string>());
}
if (vm.count("nbds_max")) {
if (vm_deprecated.count("nbds_max")) {
opts.push_back("nbds_max=" + vm_deprecated["nbds_max"].as<std::string>());
}
if (vm.count("max_part")) {
if (vm_deprecated.count("max_part")) {
opts.push_back("max_part=" + vm_deprecated["max_part"].as<std::string>());
}
if (vm.count("timeout")) {
if (vm_deprecated.count("timeout")) {
opts.push_back("timeout=" + vm_deprecated["timeout"].as<std::string>());
}

Expand Down

0 comments on commit 90892fd

Please sign in to comment.