]>
git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/plugins/plugin.py
1 from typing
import no_type_check
3 from mgr_module
import Command
, Option
5 from . import PLUGIN_MANAGER
as PM
6 from . import interfaces
as I
# noqa: E741,N812
9 class SimplePlugin(I
.CanMgr
, I
.HasOptions
, I
.HasCommands
):
11 Helper class that provides simplified creation of plugins:
12 - Default Mixins/Interfaces: CanMgr, HasOptions & HasCommands
13 - Options are defined by OPTIONS class variable, instead from get_options hook
14 - Commands are created with by COMMANDS list of Commands() and handlers
15 (less compact than CLICommand, but allows using method instances)
21 def get_options(self
):
22 return self
.OPTIONS
# type: ignore
25 @no_type_check # https://github.com/python/mypy/issues/7806
26 def get_option(self
, option
):
27 return self
.mgr
.get_module_option(option
)
30 @no_type_check # https://github.com/python/mypy/issues/7806
31 def set_option(self
, option
, value
):
32 self
.mgr
.set_module_option(option
, value
)
35 @no_type_check # https://github.com/python/mypy/issues/7806
36 def register_commands(self
):
37 for cmd
in self
.COMMANDS
:
38 cmd
.register(instance
=self
)