ceph-mgr plugin author guide ============================ Creating a plugin ----------------- In pybind/mgr/, create a python module. Within your module, create a class that inherits from ``MgrModule``. The most important methods to override are: * a ``serve`` member function for server-type modules. This function should block forever. * a ``notify`` member function if your module needs to take action when new cluster data is available. * a ``handle_command`` member function if your module exposes CLI commands. Installing a plugin ------------------- Once your module is present in the location set by the ``mgr module path`` configuration setting, you can enable it via the ``ceph mgr module enable`` command:: ceph mgr module enable mymodule Note that the MgrModule interface is not stable, so any modules maintained outside of the Ceph tree are liable to break when run against any newer or older versions of Ceph. Logging ------- ``MgrModule`` instances have a ``log`` property which is a logger instance that sends log messages into the Ceph logging layer where they will be recorded in the mgr daemon's log file. Use it the same way you would any other python logger. The python log levels debug, info, warn, err are mapped into the Ceph severities 20, 4, 1 and 0 respectively. Exposing commands ----------------- Set the ``COMMANDS`` class attribute of your plugin to a list of dicts like this:: COMMANDS = [ { "cmd": "foobar name=myarg,type=CephString", "desc": "Do something awesome", "perm": "rw", # optional: "poll": "true" } ] The ``cmd`` part of each entry is parsed in the same way as internal Ceph mon and admin socket commands (see mon/MonCommands.h in the Ceph source for examples). Note that the "poll" field is optional, and is set to False by default. Configuration options --------------------- Modules can load and store configuration options using the ``set_config`` and ``get_config`` methods. .. note:: Use ``set_config`` and ``get_config`` to manage user-visible configuration options that are not blobs (like certificates). If you want to persist module-internal data or binary configuration data consider using the `KV store`_. You must declare your available configuration options in the ``OPTIONS`` class attribute, like this: :: OPTIONS = [ { "name": "my_option" } ] If you try to use set_config or get_config on options not declared in ``OPTIONS``, an exception will be raised. You may choose to provide setter commands in your module to perform high level validation. Users can also modify configuration using the normal `ceph config set` command, where the configuration options for a mgr module are named like `mgr//