This pull request adds support for dynamically loaded plugins
The Sunfish core library uses a plugin mechanism that allows dynamic loading of certain classes. This helps users with updating the behavior of the sunfish library without having to modify its core classes. At the moment we support plugins for the storage backend, for the redfish event handlers and for the main redifsh objects handlers. Plugins are implemented as namespaced packages and must be placed in a folder at the top of the project named "sunfish_plugins", with subfolders named "storage" and/or "events_handlers" and/or "objects_handlers". The python packages defined inside each subfolder are totally user defined.
── sunfish_plugins
├── storage
│ └──my_storage_package <--- User defined
│ ├── __init__.py
│ └── my_storage_backend.py
└── events_handlers
│ └──my_handler_package <--- User defined
│ ├── __init__.py
│ └── my_handler.py
└── objects_handlers
└──my_objects_handler_package <--- User defined
├── __init__.py
└── my_objects_handler.py
When initializing the Sunfish libraries can load their storage or event handler plugin by specifying them in the configuration as in the below example:
In all cases "class_name" represents the name of the class that is initialized and implements the respective interface.
The object _handler interface is not only defining which handler to execute for each specific RedFish object but also the actions to execute when forwarding the current request to the object manager (i.e., the agent). The ObjectHandlerInterface class includes a method called forward_to_manager that is used exactly for this purpose.
This pull request adds support for dynamically loaded plugins
The Sunfish core library uses a plugin mechanism that allows dynamic loading of certain classes. This helps users with updating the behavior of the sunfish library without having to modify its core classes. At the moment we support plugins for the storage backend, for the redfish event handlers and for the main redifsh objects handlers. Plugins are implemented as namespaced packages and must be placed in a folder at the top of the project named "sunfish_plugins", with subfolders named "storage" and/or "events_handlers" and/or "objects_handlers". The python packages defined inside each subfolder are totally user defined.
When initializing the Sunfish libraries can load their storage or event handler plugin by specifying them in the configuration as in the below example:
In all cases "class_name" represents the name of the class that is initialized and implements the respective interface.
The object _handler interface is not only defining which handler to execute for each specific RedFish object but also the actions to execute when forwarding the current request to the object manager (i.e., the agent). The
ObjectHandlerInterface
class includes a method calledforward_to_manager
that is used exactly for this purpose.