]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr,pybind/mgr: use bool for poll in COMMANDS
authorKefu Chai <kchai@redhat.com>
Sun, 17 Jan 2021 01:16:36 +0000 (09:16 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 24 Jan 2021 14:16:36 +0000 (22:16 +0800)
use correctly typed variable helps with readability and less
error-prone.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mgr/PyModule.cc
src/pybind/mgr/insights/module.py
src/pybind/mgr/iostat/module.py

index 07461af3b887c52d11a0101b0f09e95367470fa7..48295a7a5bc6d2d0cca63ac1d0b08c4ffa029a36 100644 (file)
@@ -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;
index 001bfb62061acebe1a12e99986c654fef62041ff..1b6865bcbd3317b12543ec5c64341ed0b0b55fdb 100644 (file)
@@ -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> hours',
             'perm': 'rw',
-            "poll": "false",
+            "poll": False,
         },
     ]
 
index f5c3179ded1cbd8463e7e96d60f39c5b0efe77a1..215187377c225b6704afe390d9ad798e7dbf64fa 100644 (file)
@@ -8,7 +8,7 @@ class Module(MgrModule):
             "cmd": "iostat",
             "desc": "Get IO rates",
             "perm": "r",
-            "poll": "true"
+            "poll": True
         },
     ]