mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Improved Modern Modules (#14315)
* Improved Modern Modules Modules now report module dependencies and can dump data for testing This should serve to the process of building a module more obvious. cleanup now only requires a device, not an os wrapped around a device Helper to create a modern module (including the legacy adapter) from a name. * return false correctly for dump and handle it. * make sure test data is in the right format. * wrong isis table name * sort * Fix style and lint issues
This commit is contained in:
@@ -25,17 +25,23 @@
|
||||
|
||||
namespace LibreNMS\Interfaces;
|
||||
|
||||
use App\Models\Device;
|
||||
use LibreNMS\OS;
|
||||
|
||||
interface Module
|
||||
{
|
||||
/**
|
||||
* An array of all modules this module depends on
|
||||
*/
|
||||
public function dependencies(): array;
|
||||
|
||||
/**
|
||||
* Discover this module. Heavier processes can be run here
|
||||
* Run infrequently (default 4 times a day)
|
||||
*
|
||||
* @param \LibreNMS\OS $os
|
||||
*/
|
||||
public function discover(OS $os);
|
||||
public function discover(OS $os): void;
|
||||
|
||||
/**
|
||||
* Poll data for this module and update the DB / RRD.
|
||||
@@ -44,13 +50,24 @@ interface Module
|
||||
*
|
||||
* @param \LibreNMS\OS $os
|
||||
*/
|
||||
public function poll(OS $os);
|
||||
public function poll(OS $os): void;
|
||||
|
||||
/**
|
||||
* Remove all DB data for this module.
|
||||
* This will be run when the module is disabled.
|
||||
*
|
||||
* @param \LibreNMS\OS $os
|
||||
* @param \App\Models\Device $device
|
||||
*/
|
||||
public function cleanup(OS $os);
|
||||
public function cleanup(Device $device): void;
|
||||
|
||||
/**
|
||||
* Dump current module data for the given device for tests.
|
||||
* Make sure to hide transient fields, such as id and date.
|
||||
* You should always order the data by a non-transient column.
|
||||
* Some id fields may need to be joined to tie back to non-transient data.
|
||||
* Module may return false if testing is not supported or required.
|
||||
*
|
||||
* @return array|false
|
||||
*/
|
||||
public function dump(Device $device);
|
||||
}
|
||||
|
Reference in New Issue
Block a user