From: Kefu Chai Date: Sun, 17 Jan 2021 01:16:36 +0000 (+0800) Subject: mgr,pybind/mgr: use bool for poll in COMMANDS X-Git-Tag: v16.2.0~230^2~40 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4b93fe73a2eafcd337992179550a676bedf95a69;p=ceph.git 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 (cherry picked from commit 1453f0ff1f57ef4473bbdc0a6037c8316e8fec21) --- diff --git a/src/mgr/PyModule.cc b/src/mgr/PyModule.cc index 07461af3b887..48295a7a5bc6 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 001bfb62061a..1b6865bcbd33 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 f5c3179ded1c..215187377c22 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 }, ]