[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ceph-commit
Subject:    [ceph-commit] branch master updated. v9.0.0-1116-g013f9af
From:       ceph-commit () ceph ! com (ceph ! git)
Date:       2015-05-30 0:45:07
Message-ID: 20150530004508.16F113F765 () ds3426 ! dreamservers ! com
[Download RAW message or body]

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".

The branch, master has been updated
       via  013f9af82c201646bd228467d436d81a905700c0 (commit)
       via  a808c814b029dd7ddf4bb70a485bad94fbbdfb61 (commit)
       via  aa62dcbe39f003c599688f6a3003c746773fdd86 (commit)
      from  64096b870960d021ab5001b6a5cf3a999a9abeb7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 013f9af82c201646bd228467d436d81a905700c0
Merge: 64096b8 a808c81
Author: Sage Weil <sage at redhat.com>
Date:   Fri May 29 17:43:54 2015 -0700

    Merge pull request #4727 from tchaikov/wip-osdmaptool-dump-tree-with-format
    
    osdmaptool: dump tree with given format
    
    Reviewed-by: Sage Weil <sage at redhat.com>

commit a808c814b029dd7ddf4bb70a485bad94fbbdfb61
Author: Kefu Chai <kchai at redhat.com>
Date:   Wed May 20 14:24:48 2015 +0800

    osdmap, mon: switch the params of print_tree()
    
    * change from
        print_tree(ostream*, Formatter*)
      to
        print_tree(Formatter*, ostream*)
      this is more consistent with other map's print
      functions. e.g.
        MDSMap::print_summary(Formatter *f, ostream *out)
    * and in print_tree(Formatter* f, ostream* os),
      - `f` and `os` will be mutual exclusive.
      - will assert(0) if both of them are NULL.
    
    Signed-off-by: Kefu Chai <kchai at redhat.com>

commit aa62dcbe39f003c599688f6a3003c746773fdd86
Author: Kefu Chai <kchai at redhat.com>
Date:   Wed May 20 14:16:14 2015 +0800

    osdmaptool: dump 'osd tree' in specified format
    
    * so we are able to dump more info from osdmap using this tool,
      and this allows us to reproduce the behavior of "ceph osd tree".
    * add a test for 'osdmaptool --tree=<format> filepath'
    
    Signed-off-by: Kefu Chai <kchai at redhat.com>

-----------------------------------------------------------------------

Summary of changes:
 src/mon/OSDMonitor.cc          |    4 ++--
 src/osd/OSDMap.cc              |    9 +++++----
 src/osd/OSDMap.h               |    2 +-
 src/test/cli/osdmaptool/tree.t |   19 +++++++++++++++++++
 src/tools/osdmaptool.cc        |   20 ++++++++++++++++----
 5 files changed, 43 insertions(+), 11 deletions(-)
 create mode 100644 src/test/cli/osdmaptool/tree.t

diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc
index 61b962b..0fb63cf 100644
--- a/src/mon/OSDMonitor.cc
+++ b/src/mon/OSDMonitor.cc
@@ -2945,11 +2945,11 @@ bool OSDMonitor::preprocess_command(MMonCommand *m)
     } else if (prefix == "osd tree") {
       if (f) {
 	f->open_object_section("tree");
-	p->print_tree(NULL, f.get());
+	p->print_tree(f.get(), NULL);
 	f->close_section();
 	f->flush(ds);
       } else {
-	p->print_tree(&ds, NULL);
+	p->print_tree(NULL, &ds);
       }
       rdata.append(ds);
     } else if (prefix == "osd getmap") {
diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc
index 4ce8984..8d29147 100644
--- a/src/osd/OSDMap.cc
+++ b/src/osd/OSDMap.cc
@@ -2561,15 +2561,16 @@ private:
   const OSDMap *osdmap;
 };
 
-void OSDMap::print_tree(ostream *out, Formatter *f) const
+void OSDMap::print_tree(Formatter *f, ostream *out) const
 {
-  if (out) {
+  if (f)
+    OSDTreeFormattingDumper(crush.get(), this).dump(f);
+  else {
+    assert(out);
     TextTable tbl;
     OSDTreePlainDumper(crush.get(), this).dump(&tbl);
     *out << tbl;
   }
-  if (f)
-    OSDTreeFormattingDumper(crush.get(), this).dump(f);
 }
 
 void OSDMap::print_summary(Formatter *f, ostream& out) const
diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h
index 3e17d30..643ee10 100644
--- a/src/osd/OSDMap.h
+++ b/src/osd/OSDMap.h
@@ -842,7 +842,7 @@ public:
   void print_pools(ostream& out) const;
   void print_summary(Formatter *f, ostream& out) const;
   void print_oneline_summary(ostream& out) const;
-  void print_tree(ostream *out, Formatter *f) const;
+  void print_tree(Formatter *f, ostream *out) const;
 
   string get_flag_string() const;
   static string get_flag_string(unsigned flags);
diff --git a/src/test/cli/osdmaptool/tree.t b/src/test/cli/osdmaptool/tree.t
new file mode 100644
index 0000000..00eb0be
--- /dev/null
+++ b/src/test/cli/osdmaptool/tree.t
@@ -0,0 +1,19 @@
+  $ osdmaptool --createsimple 3 om
+  osdmaptool: osdmap file 'om'
+  osdmaptool: writing epoch 1 to om
+
+  $ osdmaptool --tree=plain om
+  osdmaptool: osdmap file 'om'
+  ID WEIGHT  TYPE NAME              UP/DOWN REWEIGHT PRIMARY-AFFINITY 
+  -1 3.00000 root default                                             
+  -3 3.00000     rack localrack                                       
+  -2 3.00000         host localhost                                   
+   0 1.00000             osd.0          DNE        0                  
+   1 1.00000             osd.1          DNE        0                  
+   2 1.00000             osd.2          DNE        0                  
+
+  $ osdmaptool --tree=json om
+  osdmaptool: osdmap file 'om'
+  {"nodes":[{"id":-1,"name":"default","type":"root","type_id":10,"children":[-3]},{"i \
d":-3,"name":"localrack","type":"rack","type_id":3,"children":[-2]},{"id":-2,"name":"l \
ocalhost","type":"host","type_id":1,"children":[2,1,0]},{"id":0,"name":"osd.0","type": \
"osd","type_id":0,"crush_weight":1.000000,"depth":3,"exists":0,"status":"down","reweig \
ht":0.000000,"primary_affinity":1.000000},{"id":1,"name":"osd.1","type":"osd","type_id \
":0,"crush_weight":1.000000,"depth":3,"exists":0,"status":"down","reweight":0.000000," \
primary_affinity":1.000000},{"id":2,"name":"osd.2","type":"osd","type_id":0,"crush_wei \
ght":1.000000,"depth":3,"exists":0,"status":"down","reweight":0.000000,"primary_affinity":1.000000}],"stray":[]}
 +  $ rm -f om
+
diff --git a/src/tools/osdmaptool.cc b/src/tools/osdmaptool.cc
index 14331c3..b547b7a 100644
--- a/src/tools/osdmaptool.cc
+++ b/src/tools/osdmaptool.cc
@@ -55,6 +55,7 @@ int main(int argc, const char **argv)
   bool print = false;
   bool print_json = false;
   bool tree = false;
+  boost::scoped_ptr<Formatter> tree_formatter;
   bool createsimple = false;
   bool create_from_conf = false;
   int num_osd = 0;
@@ -84,8 +85,11 @@ int main(int argc, const char **argv)
       print = true;
     } else if (ceph_argparse_flag(args, i, "--dump-json", (char*)NULL)) {
       print_json = true;
-    } else if (ceph_argparse_flag(args, i, "--tree", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &val, err, "--tree", (char*)NULL)) {
       tree = true;
+      if (!val.empty() && val != "plain") {
+	tree_formatter.reset(Formatter::create(val, "", "json"));
+      }
     } else if (ceph_argparse_witharg(args, i, &num_osd, err, "--createsimple", \
(char*)NULL)) {  if (!err.str().empty()) {
 	cerr << err.str() << std::endl;
@@ -465,9 +469,17 @@ int main(int argc, const char **argv)
     osdmap.print(cout);
   if (print_json)
     osdmap.dump_json(cout);
-  if (tree) 
-    osdmap.print_tree(&cout, NULL);
-
+  if (tree) {
+    if (tree_formatter) {
+      tree_formatter->open_object_section("tree");
+      osdmap.print_tree(tree_formatter.get(), NULL);
+      tree_formatter->close_section();
+      tree_formatter->flush(cout);
+      cout << std::endl;
+    } else {
+      osdmap.print_tree(NULL, &cout);
+    }
+  }
   if (modified) {
     bl.clear();
     osdmap.encode(bl, CEPH_FEATURES_SUPPORTED_DEFAULT | CEPH_FEATURE_RESERVED);


hooks/post-receive
-- 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic