mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Add ability to fetch oxidized device config via the librenms API (#10913)
* Add get_oxidized_config api route * Add "get_oxidized_config" function. * add get_oxidized_config docs and fix typo in the search_oxidized docs.
This commit is contained in:
@@ -1191,7 +1191,7 @@ Input:
|
||||
|
||||
Example:
|
||||
```curl
|
||||
curl -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/oxidized/configsearch/vlan10
|
||||
curl -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/oxidized/config/search/vlan10
|
||||
```
|
||||
|
||||
Output:
|
||||
@@ -1211,3 +1211,28 @@ Output:
|
||||
"count": 2
|
||||
}
|
||||
```
|
||||
|
||||
### `get_oxidized_config`
|
||||
|
||||
Returns a specific device's config from oxidized.
|
||||
|
||||
Route: `api/v0/oxidized/config/:device_name`
|
||||
|
||||
- device_name is the full dns name of the device used when adding the device to librenms.
|
||||
|
||||
Input:
|
||||
|
||||
-
|
||||
|
||||
Example:
|
||||
```curl
|
||||
curl -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/oxidized/config/router.corp.com
|
||||
```
|
||||
|
||||
Output:
|
||||
```json
|
||||
{
|
||||
"status": "ok",
|
||||
"config": "DEVICE CONFIG HERE"
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1204,6 +1204,17 @@ function search_oxidized(\Illuminate\Http\Request $request)
|
||||
}
|
||||
}
|
||||
|
||||
function get_oxidized_config(\Illuminate\Http\Request $request)
|
||||
{
|
||||
$hostname = $request->route('device_name');
|
||||
$result = json_decode(file_get_contents(Config::get('oxidized.url') . '/node/fetch/' . $hostname . '?format=json'), true);
|
||||
if (!$result) {
|
||||
return api_error(404, "Received no data from Oxidized");
|
||||
} else {
|
||||
return api_success($result, 'config');
|
||||
}
|
||||
}
|
||||
|
||||
function list_oxidized(\Illuminate\Http\Request $request)
|
||||
{
|
||||
$hostname = $request->route('hostname');
|
||||
|
||||
@@ -74,6 +74,7 @@ Route::group(['prefix' => 'v0', 'namespace' => '\App\Api\Controllers'], function
|
||||
Route::delete('rules/{id}', 'LegacyApiController@delete_rule')->name('delete_rule');
|
||||
Route::post('services/{hostname}', 'LegacyApiController@add_service_for_host')->name('add_service_for_host');
|
||||
Route::get('oxidized/config/search/{searchstring}', 'LegacyApiController@search_oxidized')->name('search_oxidized');
|
||||
Route::get('oxidized/config/{device_name}', 'LegacyApiController@get_oxidized_config')->name('get_oxidized_config');
|
||||
Route::post('devicegroups', 'LegacyApiController@add_device_group')->name('add_device_group');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user