]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: Extract 'srt_to_bool' method
authorTiago Melo <tmelo@suse.com>
Mon, 4 Jun 2018 13:39:06 +0000 (14:39 +0100)
committerTiago Melo <tmelo@suse.com>
Mon, 4 Jun 2018 13:49:54 +0000 (14:49 +0100)
Signed-off-by: Tiago Melo <tmelo@suse.com>
src/pybind/mgr/dashboard/controllers/pool.py
src/pybind/mgr/dashboard/tools.py

index 84c2b7a9a0cd05ba54bbb29925a8dbbbb99d857e..ae61330923130b9d758c358b415db8b6cfa9cd6a 100644 (file)
@@ -7,6 +7,7 @@ from . import ApiController, RESTController, Endpoint, AuthRequired
 from .. import mgr
 from ..services.ceph_service import CephService
 from ..services.exception import handle_send_command_error
+from ..tools import str_to_bool
 
 
 @ApiController('/pool')
@@ -37,17 +38,11 @@ class Pool(RESTController):
         res['pool_name'] = pool['pool_name']
         return res
 
-    @staticmethod
-    def _str_to_bool(var):
-        if isinstance(var, bool):
-            return var
-        return var.lower() in ("true", "yes", "1", 1)
-
     def _pool_list(self, attrs=None, stats=False):
         if attrs:
             attrs = attrs.split(',')
 
-        if self._str_to_bool(stats):
+        if str_to_bool(stats):
             pools = CephService.get_pool_list_with_stats()
         else:
             pools = CephService.get_pool_list()
index 0849f839502c095822f82520ef7b7c7319fcd008..2913eac9402ab748696e71259078184cc40b0069 100644 (file)
@@ -739,3 +739,9 @@ def getargspec(func):
     except AttributeError:
         pass
     return _getargspec(func)
+
+
+def str_to_bool(var):
+    if isinstance(var, bool):
+        return var
+    return var.lower() in ("true", "yes", "1", 1)