API: Add api call to list OSPF ports (#12955)

Signed-off-by: Misha Komarovskiy <zombah@gmail.com>
This commit is contained in:
Misha Komarovskiy 2021-06-16 21:31:05 +03:00 committed by GitHub
parent f8d9ab4d49
commit e670097bf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 68 additions and 0 deletions

View File

@ -349,6 +349,61 @@ Output:
}
```
### `list_ospf_ports`
List the current OSPF ports.
Route: `/api/v0/ospf_ports`
Example:
```curl
curl -H 'X-Auth-Token: YOURAPITOKENHERE' https://librenms.org/api/v0/ospf_ports
```
Output:
```json
{
"status": "ok",
"ospf_ports": [
{
"id": 189086,
"device_id": 43,
"port_id": 2838,
"ospf_port_id": "10.10.2.86.0",
"ospfIfIpAddress": "10.10.2.86",
"ospfAddressLessIf": 0,
"ospfIfAreaId": "0.0.0.0",
"ospfIfType": "pointToPoint",
"ospfIfAdminStat": "enabled",
"ospfIfRtrPriority": 128,
"ospfIfTransitDelay": 1,
"ospfIfRetransInterval": 5,
"ospfIfHelloInterval": 10,
"ospfIfRtrDeadInterval": 40,
"ospfIfPollInterval": 90,
"ospfIfState": "pointToPoint",
"ospfIfDesignatedRouter": "0.0.0.0",
"ospfIfBackupDesignatedRouter": "0.0.0.0",
"ospfIfEvents": 33,
"ospfIfAuthKey": "",
"ospfIfStatus": "active",
"ospfIfMulticastForwarding": "unicast",
"ospfIfDemand": "false",
"ospfIfAuthType": "0",
"ospfIfMetricIpAddress": "10.10.2.86",
"ospfIfMetricAddressLessIf": 0,
"ospfIfMetricTOS": 0,
"ospfIfMetricValue": 10,
"ospfIfMetricStatus": "active",
"context_name": null
}
],
"count": 1
}
```
### `list_vrf`
List the current VRFs.

View File

@ -16,6 +16,7 @@ use App\Models\Availability;
use App\Models\Device;
use App\Models\DeviceGroup;
use App\Models\DeviceOutage;
use App\Models\OspfPort;
use App\Models\PortGroup;
use App\Models\PortsFdb;
use App\Models\Sensor;
@ -649,6 +650,17 @@ function list_ospf(Illuminate\Http\Request $request)
return api_success($ospf_neighbours, 'ospf_neighbours');
}
function list_ospf_ports(Illuminate\Http\Request $request)
{
$ospf_ports = OspfPort::hasAccess(Auth::user())
->get();
if ($ospf_ports->isEmpty()) {
return api_error(404, 'Ospf ports do not exist');
}
return api_success($ospf_ports, 'ospf_ports', null, 200, $ospf_ports->count());
}
function get_graph_by_portgroup(Illuminate\Http\Request $request)
{
$group = $request->route('group');

View File

@ -20,6 +20,7 @@ Route::group(['prefix' => 'v0', 'namespace' => '\App\Api\Controllers'], function
Route::get('bgp', 'LegacyApiController@list_bgp')->name('list_bgp');
Route::get('bgp/{id}', 'LegacyApiController@get_bgp')->name('get_bgp');
Route::get('ospf', 'LegacyApiController@list_ospf')->name('list_ospf');
Route::get('ospf_ports', 'LegacyApiController@list_ospf_ports')->name('list_ospf_ports');
Route::get('oxidized/{hostname?}', 'LegacyApiController@list_oxidized')->name('list_oxidized');
Route::get('devicegroups/{name}', 'LegacyApiController@get_devices_by_group')->name('get_devices_by_group');
Route::get('devicegroups', 'LegacyApiController@get_device_groups')->name('get_device_groups');