mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Apply fixes from StyleCI (#12120)
This commit is contained in:
@@ -5,12 +5,12 @@ use LibreNMS\Config;
|
||||
if (Config::get('enable_pseudowires') && $device['os_group'] == 'cisco') {
|
||||
$pws_db = [];
|
||||
// Pre-cache the existing state of pseudowires for this device from the database
|
||||
$pws_db_raw = dbFetchRows('SELECT * FROM `pseudowires` WHERE `device_id` = ?', array($device['device_id']));
|
||||
$pws_db_raw = dbFetchRows('SELECT * FROM `pseudowires` WHERE `device_id` = ?', [$device['device_id']]);
|
||||
foreach ($pws_db_raw as $pw_db) {
|
||||
$pws_db[$pw_db['cpwVcID']] = $pw_db['pseudowire_id'];
|
||||
}
|
||||
|
||||
$pws = snmpwalk_cache_oid($device, 'cpwVcID', array(), 'CISCO-IETF-PW-MPLS-MIB');
|
||||
$pws = snmpwalk_cache_oid($device, 'cpwVcID', [], 'CISCO-IETF-PW-MPLS-MIB');
|
||||
$pws = snmpwalk_cache_oid($device, 'cpwVcName', $pws, 'CISCO-IETF-PW-MPLS-MIB');
|
||||
$pws = snmpwalk_cache_oid($device, 'cpwVcType', $pws, 'CISCO-IETF-PW-MPLS-MIB');
|
||||
$pws = snmpwalk_cache_oid($device, 'cpwVcPsnType', $pws, 'CISCO-IETF-PW-MPLS-MIB');
|
||||
@@ -27,15 +27,15 @@ if (Config::get('enable_pseudowires') && $device['os_group'] == 'cisco') {
|
||||
$pw['cpwVcName'] = preg_replace('/(?<=\d)_(?=\d)/', '/', $pw['cpwVcName']);
|
||||
// END
|
||||
|
||||
list($cpw_remote_id) = explode(':', $pw['cpwVcMplsPeerLdpID']);
|
||||
$cpw_remote_device = dbFetchCell('SELECT device_id from ipv4_addresses AS A, ports AS I WHERE A.ipv4_address=? AND A.port_id=I.port_id', array($cpw_remote_id));
|
||||
$if_id = dbFetchCell('SELECT port_id from ports WHERE `ifDescr`=? AND `device_id`=?', array($pw['cpwVcName'], $device['device_id']));
|
||||
if (!empty($pws_db[$pw['cpwVcID']])) {
|
||||
[$cpw_remote_id] = explode(':', $pw['cpwVcMplsPeerLdpID']);
|
||||
$cpw_remote_device = dbFetchCell('SELECT device_id from ipv4_addresses AS A, ports AS I WHERE A.ipv4_address=? AND A.port_id=I.port_id', [$cpw_remote_id]);
|
||||
$if_id = dbFetchCell('SELECT port_id from ports WHERE `ifDescr`=? AND `device_id`=?', [$pw['cpwVcName'], $device['device_id']]);
|
||||
if (! empty($pws_db[$pw['cpwVcID']])) {
|
||||
$pseudowire_id = $pws_db[$pw['cpwVcID']];
|
||||
echo '.';
|
||||
} else {
|
||||
$pseudowire_id = dbInsert(
|
||||
array(
|
||||
[
|
||||
'device_id' => $device['device_id'],
|
||||
'port_id' => $if_id,
|
||||
'peer_device_id' => $cpw_remote_device,
|
||||
@@ -45,7 +45,7 @@ if (Config::get('enable_pseudowires') && $device['os_group'] == 'cisco') {
|
||||
'pw_type' => $pw['cpwVcType'],
|
||||
'pw_descr' => $pw['cpwVcDescr'],
|
||||
'pw_psntype' => $pw['cpwVcPsnType'],
|
||||
),
|
||||
],
|
||||
'pseudowires'
|
||||
);
|
||||
echo '+';
|
||||
@@ -57,7 +57,7 @@ if (Config::get('enable_pseudowires') && $device['os_group'] == 'cisco') {
|
||||
// Cycle the list of pseudowires we cached earlier and make sure we saw them again.
|
||||
foreach ($pws_db as $pw_id => $pseudowire_id) {
|
||||
if (empty($device['pws'][$pw_id])) {
|
||||
dbDelete('pseudowires', '`pseudowire_id` = ?', array($pseudowire_id));
|
||||
dbDelete('pseudowires', '`pseudowire_id` = ?', [$pseudowire_id]);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user