From 006b0188afaa1e69a157c9fb09c6b59a3b69d0da Mon Sep 17 00:00:00 2001 From: Ernesto Puerta Date: Thu, 24 Jan 2019 19:58:42 +0100 Subject: [PATCH] mgr/dashboard: feature-toggles: add Option helper A new helper class `Options` has been added to ease adding new MODULE_OPTIONS. Fixes: http://tracker.ceph.com/issues/37530 Signed-off-by: Ernesto Puerta --- src/pybind/mgr/dashboard/module.py | 4 ---- src/pybind/mgr/mgr_module.py | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/pybind/mgr/dashboard/module.py b/src/pybind/mgr/dashboard/module.py index 051c0e72949..78b7edeabbc 100644 --- a/src/pybind/mgr/dashboard/module.py +++ b/src/pybind/mgr/dashboard/module.py @@ -19,10 +19,6 @@ from OpenSSL import crypto from mgr_module import MgrModule, MgrStandbyModule -# Imports required for CLI commands registration -# pylint: disable=unused-import -from .services import iscsi_cli - try: import cherrypy from cherrypy._cptools import HandlerWrapperTool diff --git a/src/pybind/mgr/mgr_module.py b/src/pybind/mgr/mgr_module.py index 68deb44a4fd..758db937033 100644 --- a/src/pybind/mgr/mgr_module.py +++ b/src/pybind/mgr/mgr_module.py @@ -352,6 +352,30 @@ def CLIReadCommand(prefix, args="", desc=""): def CLIWriteCommand(prefix, args="", desc=""): return CLICommand(prefix, args, desc, "w") +class Option(dict): + """ + Helper class to declare options for MODULE_OPTIONS list. + + Caveat: it uses argument names matching Python keywords (type, min, max), + so any further processing should happen in a separate method. + + TODO: type validation. + """ + def __init__( + self, name, + default=None, + type='str', + desc=None, longdesc=None, + min=None, max=None, + enum_allowed=None, + see_also=None, + tags=None, + runtime=False, + ): + super(Option, self).__init__( + (k, v) for k, v in vars().items() + if k != 'self' and v is not None) + class MgrStandbyModule(ceph_module.BaseMgrStandbyModule): """ -- 2.47.3