From: Sage Weil Date: Fri, 8 Jun 2018 22:45:25 +0000 (-0500) Subject: mgr/ActivePyModules: add get for 'device ' X-Git-Tag: v14.0.1~1030^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9662fa061ccad7d4d0ad6afcdf9f5aa51fbba2b4;p=ceph.git mgr/ActivePyModules: add get for 'device ' 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 --- diff --git a/src/mgr/ActivePyModules.cc b/src/mgr/ActivePyModules.cc index 707a6333c9288..0c411435b79d8 100644 --- a/src/mgr/ActivePyModules.cc +++ b/src/mgr/ActivePyModules.cc @@ -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(