]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/ActivePyModules: add get for 'device <devid>'
authorSage Weil <sage@redhat.com>
Fri, 8 Jun 2018 22:45:25 +0000 (17:45 -0500)
committerSage Weil <sage@redhat.com>
Sat, 23 Jun 2018 22:01:31 +0000 (17:01 -0500)
This is slightly different than the usual pattern because it is
parameterized.  I want to avoid fetching *all* devices if we don't need
it.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mgr/ActivePyModules.cc

index 707a6333c9288e03a5ea30e02660f8446ff16afc..0c411435b79d85559f4987d07b4e95ad9a8241c7 100644 (file)
@@ -281,10 +281,10 @@ PyObject *ActivePyModules::get_python(const std::string &what)
     return f.get();
   } else if (what == "pg_dump") {
     PyFormatter f;
-        cluster_state.with_pgmap(
-        [&f](const PGMap &pg_map) {
-         pg_map.dump(&f);
-        }
+    cluster_state.with_pgmap(
+      [&f](const PGMap &pg_map) {
+       pg_map.dump(&f);
+      }
     );
     return f.get();
   } else if (what == "devices") {
@@ -295,6 +295,14 @@ PyObject *ActivePyModules::get_python(const std::string &what)
       });
     f.close_section();
     return f.get();
+  } else if (what.size() > 7 &&
+            what.substr(0, 7) == "device ") {
+    string devid = what.substr(7);
+    PyFormatter f;
+    daemon_state.with_device(devid, [&f] (const DeviceState& dev) {
+       f.dump_object("device", dev);
+      });
+    return f.get();
   } else if (what == "io_rate") {
     PyFormatter f;
     cluster_state.with_pgmap(