]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: combine the namespaces of export_diff and export_full, import_diff and import.
authorDongsheng Yang <dongsheng.yang@easystack.cn>
Wed, 2 Nov 2016 08:37:32 +0000 (04:37 -0400)
committerDongsheng Yang <dongsheng.yang@easystack.cn>
Sun, 19 Feb 2017 12:42:03 +0000 (20:42 +0800)
Signed-off-by: Dongsheng Yang <dongsheng.yang@easystack.cn>
src/tools/rbd/action/Export.cc
src/tools/rbd/action/Import.cc

index b09cca65dfdc07496fb57dc80a01f45604eea8cb..f938590d3a2800abe247b2d5be68d03d8d5ab959 100644 (file)
@@ -17,6 +17,7 @@
 
 namespace rbd {
 namespace action {
+namespace export_full {
 
 struct ExportDiffContext {
   librbd::Image *image;
@@ -231,12 +232,10 @@ int do_export_diff(librbd::Image& image, const char *fromsnapname,
 }
 
 
-namespace export_diff {
-
 namespace at = argument_types;
 namespace po = boost::program_options;
 
-void get_arguments(po::options_description *positional,
+void get_arguments_diff(po::options_description *positional,
                    po::options_description *options) {
   at::add_image_or_snap_spec_options(positional, options,
                                      at::ARGUMENT_MODIFIER_SOURCE);
@@ -249,7 +248,7 @@ void get_arguments(po::options_description *positional,
   at::add_no_progress_option(options);
 }
 
-int execute(const po::variables_map &vm) {
+int execute_diff(const po::variables_map &vm) {
   size_t arg_index = 0;
   std::string pool_name;
   std::string image_name;
@@ -295,17 +294,9 @@ int execute(const po::variables_map &vm) {
 }
 
 Shell::SwitchArguments switched_arguments({at::WHOLE_OBJECT});
-Shell::Action action(
+Shell::Action action_diff(
   {"export-diff"}, {}, "Export incremental diff to file.", "",
-  &get_arguments, &execute);
-
-} // namespace export_diff
-
-
-namespace export_full {
-
-namespace at = argument_types;
-namespace po = boost::program_options;
+  &get_arguments_diff, &execute_diff);
 
 class C_Export : public Context
 {
index 4d71068128992f98e70b0a7e7bb94c3ba87550cb..0fa76f2f5c53c10f9f8ee3aeb3312a0253c31bd2 100644 (file)
@@ -19,6 +19,7 @@
 
 namespace rbd {
 namespace action {
+namespace import {
 
 int do_import_diff_fd(librbd::Image &image, int fd,
                   bool no_progress, int format)
@@ -205,12 +206,10 @@ int do_import_diff(librbd::Image &image, const char *path,
   return r;
 }
 
-namespace import_diff {
-
 namespace at = argument_types;
 namespace po = boost::program_options;
 
-void get_arguments(po::options_description *positional,
+void get_arguments_diff(po::options_description *positional,
                    po::options_description *options) {
   at::add_path_options(positional, options,
                        "import file (or '-' for stdin)");
@@ -218,7 +217,7 @@ void get_arguments(po::options_description *positional,
   at::add_no_progress_option(options);
 }
 
-int execute(const po::variables_map &vm) {
+int execute_diff(const po::variables_map &vm) {
   std::string path;
   int r = utils::get_path(vm, utils::get_positional_argument(vm, 0), &path);
   if (r < 0) {
@@ -253,16 +252,9 @@ int execute(const po::variables_map &vm) {
   return 0;
 }
 
-Shell::Action action(
-  {"import-diff"}, {}, "Import an incremental diff.", "", &get_arguments,
-  &execute);
-
-} // namespace import_diff
-
-namespace import {
-
-namespace at = argument_types;
-namespace po = boost::program_options;
+Shell::Action action_diff(
+  {"import-diff"}, {}, "Import an incremental diff.", "", &get_arguments_diff,
+  &execute_diff);
 
 class C_Import : public Context {
 public: