From 1453f0ff1f57ef4473bbdc0a6037c8316e8fec21 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 17 Jan 2021 09:16:36 +0800 Subject: [PATCH] mgr,pybind/mgr: use bool for poll in COMMANDS use correctly typed variable helps with readability and less error-prone. Signed-off-by: Kefu Chai --- src/mgr/PyModule.cc | 9 +++------ src/pybind/mgr/insights/module.py | 4 ++-- src/pybind/mgr/iostat/module.py | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/mgr/PyModule.cc b/src/mgr/PyModule.cc index 07461af3b88..48295a7a5bc 100644 --- a/src/mgr/PyModule.cc +++ b/src/mgr/PyModule.cc @@ -499,12 +499,9 @@ int PyModule::load_commands() command.perm = PyUnicode_AsUTF8(pPerm); command.polling = false; - PyObject *pPoll = PyDict_GetItemString(pCommand, "poll"); - if (pPoll) { - std::string polling = PyUnicode_AsUTF8(pPoll); - if (boost::iequals(polling, "true")) { - command.polling = true; - } + if (PyObject *pPoll = PyDict_GetItemString(pCommand, "poll"); + pPoll && PyObject_IsTrue(pPoll)) { + command.polling = true; } command.module_name = module_name; diff --git a/src/pybind/mgr/insights/module.py b/src/pybind/mgr/insights/module.py index 001bfb62061..1b6865bcbd3 100644 --- a/src/pybind/mgr/insights/module.py +++ b/src/pybind/mgr/insights/module.py @@ -23,13 +23,13 @@ class Module(MgrModule): "cmd": "insights", "desc": "Retrieve insights report", "perm": "r", - "poll": "false", + "poll": False, }, { 'cmd': 'insights prune-health name=hours,type=CephString', 'desc': 'Remove health history older than hours', 'perm': 'rw', - "poll": "false", + "poll": False, }, ] diff --git a/src/pybind/mgr/iostat/module.py b/src/pybind/mgr/iostat/module.py index f5c3179ded1..215187377c2 100644 --- a/src/pybind/mgr/iostat/module.py +++ b/src/pybind/mgr/iostat/module.py @@ -8,7 +8,7 @@ class Module(MgrModule): "cmd": "iostat", "desc": "Get IO rates", "perm": "r", - "poll": "true" + "poll": True }, ] -- 2.39.5