]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tools: remove all deprecated options from the help output 34262/head
authorzhengyin <zhengyin@cmss.chinamoblie.com>
Tue, 31 Mar 2020 15:30:26 +0000 (23:30 +0800)
committerzhengyin <zhengyin@cmss.chinamoblie.com>
Tue, 7 Apr 2020 07:50:32 +0000 (15:50 +0800)
Signed-off-by: Zheng Yin <zhengyin@cmss.chinamobile.com>
src/test/cli/rbd/help.t
src/tools/rbd/ArgumentTypes.cc
src/tools/rbd/OptionPrinter.cc
src/tools/rbd/OptionPrinter.h
src/tools/rbd/Shell.cc
src/tools/rbd/Utils.cc
src/tools/rbd/action/Import.cc

index 2107c55425f5e82d5dca43ad416264d2b66e5927..1f9aff38fb957d4d54074e13ac6b8f20b2c9a20a 100644 (file)
       watch                             Watch events on image.
   
   Optional arguments:
-    -c [ --conf ] arg     path to cluster configuration
-    --cluster arg         cluster name
-    --id arg              client id (without 'client.' prefix)
-    --user arg            client id (without 'client.' prefix)
-    -n [ --name ] arg     client name
-    -m [ --mon_host ] arg monitor host
-    --secret arg          path to secret key (deprecated)
-    -K [ --keyfile ] arg  path to secret key
-    -k [ --keyring ] arg  path to keyring
+    -c [ --conf ] arg                   path to cluster configuration
+    --cluster arg                       cluster name
+    --id arg                            client id (without 'client.' prefix)
+    -n [ --name ] arg                   client name
+    -m [ --mon_host ] arg               monitor host
+    -K [ --keyfile ] arg                path to secret key
+    -k [ --keyring ] arg                path to keyring
   
   See 'rbd help <command>' for help on a specific command.
   $ rbd help | grep '^    [a-z]' | sed 's/^    \([a-z -]*[a-z]\).*/\1/g' | while read -r line; do echo rbd help $line ; rbd help $line; done
     --dest-pool arg           destination pool name
     --dest-namespace arg      destination namespace name
     --dest arg                destination image name
-    --order arg               object order [12 <= order <= 25] (deprecated)
     --object-size arg         object size in B/K/M [4K <= object size <= 32M]
     --image-feature arg       image features
                               [layering(+), exclusive-lock(+*), object-map(+*),
     --dest-pool arg              destination pool name
     --dest-namespace arg         destination namespace name
     --dest arg                   destination image name
-    --order arg                  object order [12 <= order <= 25] (deprecated)
     --object-size arg            object size in B/K/M [4K <= object size <= 32M]
     --image-feature arg          image features
                                  [layering(+), exclusive-lock(+*),
     -p [ --pool ] arg         pool name
     --namespace arg           namespace name
     --image arg               image name
-    --image-format arg        image format [1 (deprecated) or 2]
-    --new-format              use image format 2
-                              (deprecated)
-    --order arg               object order [12 <= order <= 25] (deprecated)
+    --image-format arg        image format [default: 2]
     --object-size arg         object size in B/K/M [4K <= object size <= 32M]
     --image-feature arg       image features
                               [layering(+), exclusive-lock(+*), object-map(+*),
     --dest-pool arg              destination pool name
     --dest-namespace arg         destination namespace name
     --dest arg                   destination image name
-    --order arg                  object order [12 <= order <= 25] (deprecated)
     --object-size arg            object size in B/K/M [4K <= object size <= 32M]
     --image-feature arg          image features
                                  [layering(+), exclusive-lock(+*),
     --dest-pool arg           destination pool name
     --dest-namespace arg      destination namespace name
     --dest arg                destination image name
-    --image-format arg        image format [1 (deprecated) or 2]
-    --new-format              use image format 2
-                              (deprecated)
-    --order arg               object order [12 <= order <= 25] (deprecated)
+    --image-format arg        image format [default: 2]
     --object-size arg         object size in B/K/M [4K <= object size <= 32M]
     --image-feature arg       image features
                               [layering(+), exclusive-lock(+*), object-map(+*),
     --sparse-size arg         sparse size in B/K/M [default: 4K]
     --no-progress             disable progress output
     --export-format arg       format of image file
-    -p [ --pool ] arg         pool name (deprecated)
-    --image arg               image name (deprecated)
   
   Image Features:
     (*) supports enabling/disabling on existing images
     --dest-pool arg           destination pool name
     --dest-namespace arg      destination namespace name
     --dest arg                destination image name
-    --image-format arg        image format [1 (deprecated) or 2]
-    --new-format              use image format 2
-                              (deprecated)
-    --order arg               object order [12 <= order <= 25] (deprecated)
+    --image-format arg        image format [default: 2]
     --object-size arg         object size in B/K/M [4K <= object size <= 32M]
     --image-feature arg       image features
                               [layering(+), exclusive-lock(+*), object-map(+*),
index fbf9c62831daba59c3db4dc94c0b8e3ec07b6ab5..e21c60aa3f7d15d72987a7ed6d01918d2b0734e6 100644 (file)
@@ -227,15 +227,15 @@ void add_create_image_options(po::options_description *opt,
   if (include_format) {
     opt->add_options()
       (IMAGE_FORMAT.c_str(), po::value<ImageFormat>(),
-       "image format [1 (deprecated) or 2]")
+       "image format [default: 2]")
       (IMAGE_NEW_FORMAT.c_str(),
        po::value<ImageNewFormat>()->zero_tokens(),
-       "use image format 2\n(deprecated)");
+       "deprecated[:image-format 2]");
   }
 
   opt->add_options()
     (IMAGE_ORDER.c_str(), po::value<ImageOrder>(),
-     "object order [12 <= order <= 25] (deprecated)")
+     "deprecated[:object-size]")
     (IMAGE_OBJECT_SIZE.c_str(), po::value<ImageObjectSize>(),
      "object size in B/K/M [4K <= object size <= 32M]")
     (IMAGE_FEATURES.c_str(), po::value<ImageFeatures>()->composing(),
@@ -431,8 +431,6 @@ void validate(boost::any& v, const std::vector<std::string>& values,
 
 void validate(boost::any& v, const std::vector<std::string>& values,
               ImageNewFormat *target_type, int dummy) {
-  std::cout << "rbd: --new-format is deprecated, use --image-format"
-            << std::endl;
   v = boost::any(true);
 }
 
@@ -504,7 +502,6 @@ void validate(boost::any& v, const std::vector<std::string>& values,
 
 void validate(boost::any& v, const std::vector<std::string>& values,
               Secret *target_type, int) {
-  std::cerr << "rbd: --secret is deprecated, use --keyfile" << std::endl;
 
   po::validators::check_first_occurrence(v);
   const std::string &s = po::validators::get_single_string(values);
index 14affb0b3bb85192e9f3d0ac8bbaebb55ee02b24..a1874a769dcfbf9e35000d3e07ebb800149026d5 100644 (file)
@@ -56,6 +56,28 @@ void OptionPrinter::print_short(std::ostream &os, size_t initial_offset) {
   }
 }
 
+void OptionPrinter::print_optional(const OptionsDescription &global_opts,
+                                   size_t &name_width, std::ostream &os) {
+  std::string indent2(2, ' ');
+
+  for (size_t i = 0; i < global_opts.options().size(); ++i) {
+    std::string description = global_opts.options()[i]->description();
+    auto result = boost::find_first(description, "deprecated");
+    if (!result.empty()) {
+      continue;
+    }
+    std::stringstream ss;
+    ss << indent2
+       << global_opts.options()[i]->format_name() << " "
+       << global_opts.options()[i]->format_parameter();
+
+    std::cout << ss.str();
+    IndentStream indent_stream(name_width, ss.str().size(), LINE_WIDTH, std::cout);
+    indent_stream << global_opts.options()[i]->description() << std::endl;
+  }
+
+}
+
 void OptionPrinter::print_detailed(std::ostream &os) {
   std::string indent_prefix(2, ' ');
   size_t name_width = compute_name_width(indent_prefix.size());
@@ -76,16 +98,7 @@ void OptionPrinter::print_detailed(std::ostream &os) {
 
   if (m_optional.options().size() > 0) {
     std::cout << OPTIONAL_ARGUMENTS << std::endl;
-    for (size_t i = 0; i < m_optional.options().size(); ++i) {
-      std::stringstream ss;
-      ss << indent_prefix
-         << m_optional.options()[i]->format_name() << " "
-         << m_optional.options()[i]->format_parameter();
-
-      std::cout << ss.str();
-      IndentStream indent_stream(name_width, ss.str().size(), LINE_WIDTH, os);
-      indent_stream << m_optional.options()[i]->description() << std::endl;
-    }
+    print_optional(m_optional, name_width, os);
     std::cout << std::endl;
   }
 }
index 02bb8e1c27420b992825f0c012f4d5594815db41..06d3a3c991419a761dede50ac599cb27469100ae 100644 (file)
@@ -7,6 +7,7 @@
 #include "include/int_types.h"
 #include <string>
 #include <vector>
+#include <boost/algorithm/string.hpp>
 #include <boost/program_options.hpp>
 
 namespace rbd {
@@ -27,6 +28,8 @@ public:
 
   void print_short(std::ostream &os, size_t initial_offset);
   void print_detailed(std::ostream &os);
+  static void print_optional(const OptionsDescription &global_opts,
+                             size_t &name_width, std::ostream &os);
 
 private:
   const OptionsDescription &m_positional;
index 9993c691b4105bdac9edae216f466f9386a0fc51..15080f372b01af913a66c459da897af90d2e8016 100644 (file)
@@ -122,6 +122,15 @@ std::set<std::string>& Shell::get_switch_arguments() {
   return switch_arguments;
 }
 
+void print_deprecated_warning(po::option_description option, std::string description) {
+  auto pos = description.find_first_of(":");
+  if (pos != std::string::npos) {
+  std::string param = description.substr(pos + 1, description.size() - pos - 2);
+  std::cout << "rbd: " << option.format_name() << " is deprecated, use --"
+            << param << std::endl;
+  }
+}
+
 int Shell::execute(int argc, const char **argv) {
   std::vector<std::string> arguments;
   std::vector<std::string> ceph_global_init_args;
@@ -202,6 +211,46 @@ int Shell::execute(int argc, const char **argv) {
     }
 
     int r = (*action->execute)(vm, ceph_global_init_args);
+
+    if (vm.size() > 0) {
+      for (auto opt : vm) {
+        try {
+          auto option = command_opts.find(opt.first, false);
+          auto description = option.description();
+          auto result = boost::find_first(description, "deprecated");
+          if (!result.empty()) {
+            print_deprecated_warning(option, description);
+          }
+        } catch (exception& e) {
+          continue;
+        }
+      }
+    }
+
+    po::options_description global_opts;
+    get_global_options(&global_opts);
+    auto it = ceph_global_init_args.begin();
+    for ( ; it != ceph_global_init_args.end(); ++it) {
+      auto  pos = (*it).find_last_of("-");
+      auto prefix_style = po::command_line_style::allow_long;
+      if (pos == 0) {
+        prefix_style = po::command_line_style::allow_dash_for_short;
+      } else if (pos == std::string::npos) {
+        continue;
+      }
+
+      for (size_t i = 0; i < global_opts.options().size(); ++i) {
+        std::string param_name =  global_opts.options()[i]->canonical_display_name(
+                                  prefix_style);
+        auto description = global_opts.options()[i]->description();
+        auto result = boost::find_first(description, "deprecated");
+        if (!result.empty() && *it == param_name) {
+          print_deprecated_warning(*global_opts.options()[i], description);
+          break;
+        }
+      }
+    }
+
     if (r != 0) {
       return std::abs(r);
     }
@@ -290,10 +339,10 @@ void Shell::get_global_options(po::options_description *opts) {
     ((at::CONFIG_PATH + ",c").c_str(), po::value<std::string>(), "path to cluster configuration")
     ("cluster", po::value<std::string>(), "cluster name")
     ("id", po::value<std::string>(), "client id (without 'client.' prefix)")
-    ("user", po::value<std::string>(), "client id (without 'client.' prefix)")
+    ("user", po::value<std::string>(), "deprecated[:id]")
     ("name,n", po::value<std::string>(), "client name")
     ("mon_host,m", po::value<std::string>(), "monitor host")
-    ("secret", po::value<at::Secret>(), "path to secret key (deprecated)")
+    ("secret", po::value<at::Secret>(), "deprecated[:keyfile]")
     ("keyfile,K", po::value<std::string>(), "path to secret key")
     ("keyring,k", po::value<std::string>(), "path to keyring");
 }
@@ -343,9 +392,13 @@ void Shell::print_help() {
     }
   }
 
-  po::options_description global_opts(OptionPrinter::OPTIONAL_ARGUMENTS);
+  po::options_description global_opts;
   get_global_options(&global_opts);
-  std::cout << std::endl << global_opts << std::endl
+
+  std::cout << std::endl << OptionPrinter::OPTIONAL_ARGUMENTS << ":" << std::endl;
+  OptionPrinter::print_optional(global_opts, name_width, std::cout);
+
+  std::cout << std::endl
             << "See '" << APP_NAME << " help <command>' for help on a specific "
             << "command." << std::endl;
  }
index 520b654714b8cea012194b33cc4f6d1cae7f31b9..f02adb8a32ee2853f6cc7fe013332f05047d07af 100644 (file)
@@ -439,8 +439,6 @@ int get_image_options(const boost::program_options::variables_map &vm,
 
   if (vm.count(at::IMAGE_ORDER)) {
     order = vm[at::IMAGE_ORDER].as<uint64_t>();
-    std::cerr << "rbd: --order is deprecated, use --object-size"
-             << std::endl;
   } else if (vm.count(at::IMAGE_OBJECT_SIZE)) {
     object_size = vm[at::IMAGE_OBJECT_SIZE].as<uint64_t>();
     order = std::round(std::log2(object_size));
index b4292b336ea6b5b6a499524e8f1fe74793165c78..d1eb84a82f5270041af8b901548b4b01528c5b00 100644 (file)
@@ -945,8 +945,8 @@ void get_arguments(po::options_description *positional,
 
   // TODO legacy rbd allowed import to accept both 'image'/'dest' and
   //      'pool'/'dest-pool'
-  at::add_pool_option(options, at::ARGUMENT_MODIFIER_NONE, " (deprecated)");
-  at::add_image_option(options, at::ARGUMENT_MODIFIER_NONE, " (deprecated)");
+  at::add_pool_option(options, at::ARGUMENT_MODIFIER_NONE, " deprecated[:dest-pool]");
+  at::add_image_option(options, at::ARGUMENT_MODIFIER_NONE, " deprecated[:dest]");
 }
 
 int execute(const po::variables_map &vm,
@@ -962,15 +962,11 @@ int execute(const po::variables_map &vm,
   std::string deprecated_pool_name;
   if (vm.count(at::POOL_NAME)) {
     deprecated_pool_name = vm[at::POOL_NAME].as<std::string>();
-    std::cerr << "rbd: --pool is deprecated for import, use --dest-pool"
-              << std::endl;
   }
 
   std::string deprecated_image_name;
   if (vm.count(at::IMAGE_NAME)) {
     deprecated_image_name = vm[at::IMAGE_NAME].as<std::string>();
-    std::cerr << "rbd: --image is deprecated for import, use --dest"
-              << std::endl;
   } else {
     deprecated_image_name = path.substr(path.find_last_of("/") + 1);
   }