From 32a28e401bb7606df63b703c7c3776d62434e3a1 Mon Sep 17 00:00:00 2001 From: Tiago Melo Date: Mon, 4 Jun 2018 14:39:06 +0100 Subject: [PATCH] mgr/dashboard: Extract 'srt_to_bool' method Signed-off-by: Tiago Melo --- src/pybind/mgr/dashboard/controllers/pool.py | 9 ++------- src/pybind/mgr/dashboard/tools.py | 6 ++++++ 2 files changed, 8 insertions(+), 7 deletions(-) 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) -- 2.39.5