mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
bug - timos MPLS - more poller fixes (#15624)
* fix 1, ErrorException: Undefined array key sdpFarEndInetAddress in /opt/librenms/LibreNMS/OS/Timos.php:584 * fix2: don't try mplsSdpBinds polling if prerequisites not met * fix 3: ErrorException: Attempt to read property lsp_path_id on null in /opt/librenms/LibreNMS/OS/Timos.php:790 * style * fix phpstan * schema_update * schema * migration_style * migration drops and recreate * migration drops and recreate * migration drops and recreate * style
This commit is contained in:
@@ -140,13 +140,13 @@ class Mpls implements Module
|
||||
$svcs = $this->syncModels($device, 'mplsServices', $os->pollMplsServices());
|
||||
}
|
||||
|
||||
if ($device->mplsSaps()->exists()) {
|
||||
if ($device->mplsSaps()->exists() && isset($svcs)) {
|
||||
echo "\nMPLS SAPs: ";
|
||||
ModuleModelObserver::observe(\App\Models\MplsSap::class);
|
||||
$this->syncModels($device, 'mplsSaps', $os->pollMplsSaps($svcs));
|
||||
}
|
||||
|
||||
if ($device->mplsSdpBinds()->exists()) {
|
||||
if ($device->mplsSdpBinds()->exists() && isset($sdps, $svcs)) {
|
||||
echo "\nMPLS SDP Bindings: ";
|
||||
ModuleModelObserver::observe(\App\Models\MplsSdpBind::class);
|
||||
$this->syncModels($device, 'mplsSdpBinds', $os->pollMplsSdpBinds($sdps, $svcs));
|
||||
|
@@ -581,7 +581,10 @@ class Timos extends OS implements MplsDiscovery, MplsPolling, WirelessPowerDisco
|
||||
$ip = long2ip(hexdec(str_replace(' ', '', $value['sdpFarEndInetAddress'])));
|
||||
} else {
|
||||
//Fixme implement ipv6 conversion
|
||||
$ip = $value['sdpFarEndInetAddress'];
|
||||
//$value['sdpFarEndInetAddress'] might still be any of these:
|
||||
// -> unknown(0), ipv4(1), ipv6(2), ipv4z(3), ipv6z(4), dns(16)
|
||||
|
||||
$ip = $value['sdpFarEndInetAddress'] ?? null;
|
||||
}
|
||||
$sdps->push(new MplsSdp([
|
||||
'sdp_oid' => $value['sdpId'],
|
||||
@@ -787,7 +790,11 @@ class Timos extends OS implements MplsDiscovery, MplsPolling, WirelessPowerDisco
|
||||
$arhops = new Collection();
|
||||
foreach ($mplsTunnelArHopCache as $key => $value) {
|
||||
[$mplsTunnelARHopListIndex, $mplsTunnelARHopIndex] = explode('.', $key);
|
||||
$lsp_path_id = $paths->firstWhere('mplsLspPathTunnelARHopListIndex', $mplsTunnelARHopListIndex)->lsp_path_id;
|
||||
$firstPath = $paths->firstWhere('mplsLspPathTunnelARHopListIndex', $mplsTunnelARHopListIndex);
|
||||
if (! isset($firstPath)) {
|
||||
continue;
|
||||
}
|
||||
$lsp_path_id = $firstPath->lsp_path_id;
|
||||
$protection = intval($value['vRtrMplsTunnelARHopProtection'] ?? 0, 16);
|
||||
|
||||
$localLinkProtection = ($protection & $localAvailable) ? 'true' : 'false';
|
||||
|
34
database/migrations/2023_12_08_184652_mpls_addrtype_fix.php
Normal file
34
database/migrations/2023_12_08_184652_mpls_addrtype_fix.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('mpls_sdps', function ($table) {
|
||||
// drop and recreate because of SQLite not accepting any changes.
|
||||
// data is collected again next poll anyway.
|
||||
$table->dropColumn(['sdpFarEndInetAddressType']);
|
||||
});
|
||||
Schema::table('mpls_sdps', function ($table) {
|
||||
$table->enum('sdpFarEndInetAddressType', ['unknown', 'ipv4', 'ipv6', 'ipv4z', 'ipv6z', 'dns'])->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('mpls_sdps', function ($table) {
|
||||
$table->dropColumn(['sdpFarEndInetAddressType']);
|
||||
});
|
||||
Schema::table('mpls_sdps', function ($table) {
|
||||
$table->enum('sdpFarEndInetAddressType', ['ipv4', 'ipv6'])->nullable();
|
||||
});
|
||||
}
|
||||
};
|
@@ -1078,8 +1078,8 @@ mpls_sdps:
|
||||
- { Field: sdpLastMgmtChange, Type: bigint, 'Null': true, Extra: '' }
|
||||
- { Field: sdpLastStatusChange, Type: bigint, 'Null': true, Extra: '' }
|
||||
- { Field: sdpActiveLspType, Type: "enum('not-applicable','rsvp','ldp','bgp','none','mplsTp','srIsis','srOspf','srTeLsp','fpe')", 'Null': true, Extra: '' }
|
||||
- { Field: sdpFarEndInetAddressType, Type: "enum('ipv4','ipv6')", 'Null': true, Extra: '' }
|
||||
- { Field: sdpFarEndInetAddress, Type: varchar(46), 'Null': true, Extra: '' }
|
||||
- { Field: sdpFarEndInetAddressType, Type: "enum('unknown','ipv4','ipv6','ipv4z','ipv6z','dns')", 'Null': true, Extra: '' }
|
||||
Indexes:
|
||||
PRIMARY: { Name: PRIMARY, Columns: [sdp_id], Unique: true, Type: BTREE }
|
||||
mpls_sdps_device_id_index: { Name: mpls_sdps_device_id_index, Columns: [device_id], Unique: false, Type: BTREE }
|
||||
|
@@ -50,16 +50,6 @@ parameters:
|
||||
count: 2
|
||||
path: LibreNMS/Modules/Mpls.php
|
||||
|
||||
-
|
||||
message: "#^Variable \\$sdps might not be defined\\.$#"
|
||||
count: 1
|
||||
path: LibreNMS/Modules/Mpls.php
|
||||
|
||||
-
|
||||
message: "#^Variable \\$svcs might not be defined\\.$#"
|
||||
count: 2
|
||||
path: LibreNMS/Modules/Mpls.php
|
||||
|
||||
-
|
||||
message: "#^Variable \\$features on left side of \\?\\? is never defined\\.$#"
|
||||
count: 1
|
||||
|
Reference in New Issue
Block a user