Skip to content

Commit

Permalink
Fixed OSPF duplicate DB entries (#9051)
Browse files Browse the repository at this point in the history
Re-write ospf polling using Eloquent

DO NOT DELETE THIS TEXT

#### Please note

> Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting.

- [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/)

#### Testers

If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
  • Loading branch information
murrant authored and laf committed Aug 21, 2018
1 parent 29d51f4 commit 4158615
Show file tree
Hide file tree
Showing 7 changed files with 348 additions and 348 deletions.
59 changes: 59 additions & 0 deletions app/Models/OspfArea.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
/**
* OspfArea.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2018 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/

namespace App\Models;

class OspfArea extends BaseModel
{
public $timestamps = false;
protected $fillable = [
'device_id',
'context_name',
'ospfAreaId',
'ospfAuthType',
'ospfImportAsExtern',
'ospfSpfRuns',
'ospfAreaBdrRtrCount',
'ospfAsBdrRtrCount',
'ospfAreaLsaCount',
'ospfAreaLsaCksumSum',
'ospfAreaSummary',
'ospfAreaStatus',
];

// ---- Query Scopes ----

public function scopeHasAccess($query, User $user)
{
return $this->hasDeviceAccess($query, $user);
}

// ---- Define Relationships ----

public function device()
{
return $this->belongsTo('App\Models\Device', 'device_id');
}
}
20 changes: 19 additions & 1 deletion app/Models/OspfInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,25 @@
class OspfInstance extends BaseModel
{
public $timestamps = false;
protected $primaryKey = 'ospf_instance_id';
protected $fillable = [
'device_id',
'ospf_instance_id',
'context_name',
'ospfRouterId',
'ospfAdminStat',
'ospfVersionNumber',
'ospfAreaBdrRtrStatus',
'ospfASBdrRtrStatus',
'ospfExternLsaCount',
'ospfExternLsaCksumSum',
'ospfTOSSupport',
'ospfOriginateNewLsas',
'ospfRxNewLsas',
'ospfExtLsdbLimit',
'ospfMulticastExtensions',
'ospfExitOverflowInterval',
'ospfDemandExtensions',
];

// ---- Query Scopes ----

Expand Down
62 changes: 62 additions & 0 deletions app/Models/OspfNbr.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/**
* OspfNbr.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2018 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/

namespace App\Models;

class OspfNbr extends BaseModel
{
public $timestamps = false;
protected $fillable = [
'device_id',
'port_id',
'ospf_nbr_id',
'context_name',
'ospfNbrIpAddr',
'ospfNbrAddressLessIndex',
'ospfNbrRtrId',
'ospfNbrOptions',
'ospfNbrPriority',
'ospfNbrState',
'ospfNbrEvents',
'ospfNbrLsRetransQLen',
'ospfNbmaNbrStatus',
'ospfNbmaNbrPermanence',
'ospfNbrHelloSuppressed',
];

// ---- Query Scopes ----

public function scopeHasAccess($query, User $user)
{
return $this->hasDeviceAccess($query, $user);
}

// ---- Define Relationships ----

public function device()
{
return $this->belongsTo('App\Models\Device', 'device_id');
}
}
71 changes: 71 additions & 0 deletions app/Models/OspfPort.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?php
/**
* OspfPort.php
*
* -Description-
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package LibreNMS
* @link http://librenms.org
* @copyright 2018 Tony Murray
* @author Tony Murray <murraytony@gmail.com>
*/

namespace App\Models;

class OspfPort extends BaseModel
{
public $timestamps = false;
protected $fillable = [
'device_id',
'port_id',
'ospf_port_id',
'context_name',
'ospfIfIpAddress',
'ospfAddressLessIf',
'ospfIfAreaId',
'ospfIfType',
'ospfIfAdminStat',
'ospfIfRtrPriority',
'ospfIfTransitDelay',
'ospfIfRetransInterval',
'ospfIfHelloInterval',
'ospfIfRtrDeadInterval',
'ospfIfPollInterval',
'ospfIfState',
'ospfIfDesignatedRouter',
'ospfIfBackupDesignatedRouter',
'ospfIfEvents',
'ospfIfAuthKey',
'ospfIfStatus',
'ospfIfMulticastForwarding',
'ospfIfDemand',
'ospfIfAuthType',
];

// ---- Query Scopes ----

public function scopeHasAccess($query, User $user)
{
return $this->hasDeviceAccess($query, $user);
}

// ---- Define Relationships ----

public function device()
{
return $this->belongsTo('App\Models\Device', 'device_id');
}
}
Loading

0 comments on commit 4158615

Please sign in to comment.