]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rbd: allow librados to prune the command-line for config overrides
authorJason Dillaman <dillaman@redhat.com>
Wed, 23 Mar 2016 19:34:17 +0000 (15:34 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 23 Mar 2016 19:34:17 +0000 (15:34 -0400)
Fixes: #15250
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/tools/rbd/Shell.cc
src/tools/rbd/Shell.h
src/tools/rbd/rbd.cc

index 76aa8ed52a14ab79a9e23a9c41ba4ba4f46c8e34..5fba993ae4d46ba2ba3111eb30f53c3d68ca742e 100644 (file)
@@ -78,11 +78,10 @@ std::set<std::string>& Shell::get_switch_arguments() {
   return switch_arguments;
 }
 
-int Shell::execute(int arg_count, const char **arg_values) {
-
-  std::vector<std::string> arguments;
-  prune_command_line_arguments(arg_count, arg_values, &arguments);
+int Shell::execute(const Arguments& cmdline_arguments) {
 
+  std::vector<std::string> arguments(cmdline_arguments.begin(),
+                                     cmdline_arguments.end());
   std::vector<std::string> command_spec;
   get_command_spec(arguments, &command_spec);
 
@@ -255,32 +254,6 @@ void Shell::get_global_options(po::options_description *opts) {
     ("keyring,k", po::value<std::string>(), "path to keyring");
 }
 
-void Shell::prune_command_line_arguments(int arg_count, const char **arg_values,
-                                         std::vector<std::string> *args) {
-
-  std::vector<std::string> config_keys;
-  g_conf->get_all_keys(&config_keys);
-  std::set<std::string> config_key_set(config_keys.begin(), config_keys.end());
-
-  args->reserve(arg_count);
-  for (int i = 1; i < arg_count; ++i) {
-    std::string arg(arg_values[i]);
-    if (arg.size() > 2 && arg.substr(0, 2) == "--") {
-      std::string option_name(arg.substr(2));
-      std::string alt_option_name(option_name);
-      std::replace(alt_option_name.begin(), alt_option_name.end(), '-', '_');
-      if (config_key_set.count(option_name) ||
-          config_key_set.count(alt_option_name)) {
-        // Ceph config override -- skip since it's handled by CephContext
-        ++i;
-        continue;
-      }
-    }
-
-    args->push_back(arg);
-  }
-}
-
 void Shell::print_help() {
   std::cout << "usage: " << APP_NAME << " <command> ..."
             << std::endl << std::endl
index b65483eee48397d2860d854bb8917066df1e932f..679213051f064061b4f196a8168b09df3ae44bdd 100644 (file)
@@ -14,6 +14,7 @@ namespace rbd {
 
 class Shell {
 public:
+  typedef std::vector<const char *> Arguments;
   typedef std::vector<std::string> CommandSpec;
 
   struct Action {
@@ -47,7 +48,7 @@ public:
     }
   };
 
-  int execute(int arg_count, const char **arg_values);
+  int execute(const Arguments &argument);
 
 private:
   static std::vector<Action *>& get_actions();
@@ -59,8 +60,6 @@ private:
                       CommandSpec **matching_spec);
 
   void get_global_options(boost::program_options::options_description *opts);
-  void prune_command_line_arguments(int arg_count, const char **arg_values,
-                                    std::vector<std::string> *args);
 
   void print_help();
   void print_action_help(Action *action);
index a83db249aa75bab69cd19eb1dccf250084edb18a..bfa18d345b68fe27c7045b1a941a9d5310de0951 100644 (file)
@@ -16,5 +16,5 @@ int main(int argc, const char **argv)
   global_init(NULL, args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
 
   rbd::Shell shell;
-  return shell.execute(argc, argv);
+  return shell.execute(args);
 }