From 9662fa061ccad7d4d0ad6afcdf9f5aa51fbba2b4 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 8 Jun 2018 17:45:25 -0500 Subject: [PATCH] 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 --- src/mgr/ActivePyModules.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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( -- 2.39.5