From: Tiago Melo Date: Mon, 4 Jun 2018 13:39:06 +0000 (+0100) Subject: mgr/dashboard: Extract 'srt_to_bool' method X-Git-Tag: v14.0.1~1193^2~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=32a28e401bb7606df63b703c7c3776d62434e3a1;p=ceph-ci.git mgr/dashboard: Extract 'srt_to_bool' method Signed-off-by: Tiago Melo --- diff --git a/src/pybind/mgr/dashboard/controllers/pool.py b/src/pybind/mgr/dashboard/controllers/pool.py index 84c2b7a9a0c..ae613309231 100644 --- a/src/pybind/mgr/dashboard/controllers/pool.py +++ b/src/pybind/mgr/dashboard/controllers/pool.py @@ -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() diff --git a/src/pybind/mgr/dashboard/tools.py b/src/pybind/mgr/dashboard/tools.py index 0849f839502..2913eac9402 100644 --- a/src/pybind/mgr/dashboard/tools.py +++ b/src/pybind/mgr/dashboard/tools.py @@ -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)