]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crushtool: add --tree option
authorSage Weil <sage@redhat.com>
Fri, 16 Jan 2015 21:16:29 +0000 (13:16 -0800)
committerSage Weil <sage@redhat.com>
Sat, 17 Jan 2015 16:58:40 +0000 (08:58 -0800)
Signed-off-by: Sage Weil <sage@redhat.com>
src/test/cli/crushtool/help.t
src/tools/crushtool.cc

index a26bd12caf3b785c52448b538e1471c75ed71633..7d549195206bdd2abcfbf7491c094e6c10d6d1e7 100644 (file)
@@ -1,6 +1,7 @@
   $ crushtool --help
   usage: crushtool ...
      --decompile|-d map    decompile a crush map to source
+     --tree                print map summary as a tree
      --compile|-c map.txt  compile a map from source
      [-o outfile [--clobber]]
                            specify output for for (de)compilation
index bca05afce8193e2cc3fd959aa20a5012fd3e7e30..80438d85276f30c8b667975be2a5dead9afd88a8 100644 (file)
@@ -86,6 +86,7 @@ void usage()
 {
   cout << "usage: crushtool ...\n";
   cout << "   --decompile|-d map    decompile a crush map to source\n";
+  cout << "   --tree                print map summary as a tree\n";
   cout << "   --compile|-c map.txt  compile a map from source\n";
   cout << "   [-o outfile [--clobber]]\n";
   cout << "                         specify output for for (de)compilation\n";
@@ -171,6 +172,7 @@ int main(int argc, const char **argv)
   bool decompile = false;
   bool test = false;
   bool display = false;
+  bool tree = false;
   int full_location = -1;
   bool write_to_file = false;
   int verbose = 0;
@@ -229,6 +231,8 @@ int main(int argc, const char **argv)
       outfn = val;
     } else if (ceph_argparse_flag(args, i, "-v", "--verbose", (char*)NULL)) {
       verbose += 1;
+    } else if (ceph_argparse_flag(args, i, "--tree", (char*)NULL)) {
+      tree = true;
     } else if (ceph_argparse_flag(args, i, "--show_utilization", (char*)NULL)) {
       display = true;
       tester.set_output_utilization(true);
@@ -442,7 +446,7 @@ int main(int argc, const char **argv)
     cerr << "cannot specify more than one of compile, decompile, and build" << std::endl;
     exit(EXIT_FAILURE);
   }
-  if (!compile && !decompile && !build && !test && !reweight && !adjust &&
+  if (!compile && !decompile && !build && !test && !reweight && !adjust && !tree &&
       add_item < 0 && full_location < 0 &&
       remove_name.empty() && reweight_name.empty()) {
     cerr << "no action specified; -h for help" << std::endl;
@@ -513,6 +517,11 @@ int main(int argc, const char **argv)
       cc.decompile(cout);
     }
   }
+  if (tree) {
+    ostringstream oss;
+    crush.dump_tree(&oss, NULL);
+    dout(1) << "\n" << oss.str() << dendl;
+  }
 
   if (compile) {
     crush.create();
@@ -631,8 +640,7 @@ int main(int argc, const char **argv)
 
     {
       ostringstream oss;
-      vector<__u32> weights(crush.get_max_devices(), 0x10000);
-      crush.dump_tree(weights, &oss, NULL);
+      crush.dump_tree(&oss, NULL);
       dout(1) << "\n" << oss.str() << dendl;
     }