mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
fix: Fix arp-tables updates (#8180)
* Fix arp-tables updates Little more complete fix this time. Don't allow context_name to be nullable... * update schema file
This commit is contained in:
committed by
Neil Lathwood
parent
8a917683ca
commit
947e53d8cc
@@ -28,7 +28,7 @@ use LibreNMS\Config;
|
||||
if (key_exists('vrf_lite_cisco', $device) && (count($device['vrf_lite_cisco'])!=0)) {
|
||||
$vrfs_lite_cisco = $device['vrf_lite_cisco'];
|
||||
} else {
|
||||
$vrfs_lite_cisco = array(array('context_name'=>null));
|
||||
$vrfs_lite_cisco = array(array('context_name'=>''));
|
||||
}
|
||||
|
||||
foreach ($vrfs_lite_cisco as $vrf) {
|
||||
@@ -42,15 +42,8 @@ foreach ($vrfs_lite_cisco as $vrf) {
|
||||
$arp_data = snmpwalk_group($device, 'ipNetToMediaPhysAddress', 'IP-MIB', 1, $arp_data);
|
||||
}
|
||||
|
||||
$sql = "SELECT * from `ipv4_mac` WHERE `device_id`=?";
|
||||
$params = array($device['device_id']);
|
||||
if (is_null($context)) {
|
||||
$sql .= ' AND `context_name` IS NULL';
|
||||
} else {
|
||||
$sql .= ' AND `context_name`=?';
|
||||
$params[] = $context;
|
||||
}
|
||||
$existing_data = dbFetchRows($sql, $params);
|
||||
$sql = "SELECT * from `ipv4_mac` WHERE `device_id`=? AND `context_name`=?";
|
||||
$existing_data = dbFetchRows($sql, array($device['device_id'], $context));
|
||||
|
||||
$ipv4_addresses = array_map(function ($data) {
|
||||
return $data['ipv4_address'];
|
||||
@@ -92,7 +85,7 @@ foreach ($vrfs_lite_cisco as $vrf) {
|
||||
'device_id' => $device['device_id'],
|
||||
'mac_address' => $mac,
|
||||
'ipv4_address' => $ip,
|
||||
'context_name' => $context,
|
||||
'context_name' => (string)$context,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -663,7 +663,7 @@ ipv4_mac:
|
||||
- { Field: device_id, Type: int(11), 'Null': true, Extra: '' }
|
||||
- { Field: mac_address, Type: varchar(32), 'Null': false, Extra: '' }
|
||||
- { Field: ipv4_address, Type: varchar(32), 'Null': false, Extra: '' }
|
||||
- { Field: context_name, Type: varchar(128), 'Null': true, Extra: '' }
|
||||
- { Field: context_name, Type: varchar(128), 'Null': false, Extra: '' }
|
||||
Indexes:
|
||||
port_id: { Name: port_id, Columns: [port_id], Unique: false, Type: BTREE }
|
||||
mac_address: { Name: mac_address, Columns: [mac_address], Unique: false, Type: BTREE }
|
||||
|
2
sql-schema/233.sql
Normal file
2
sql-schema/233.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
UPDATE `ipv4_mac` SET `context_name`='' WHERE `context_name` IS NULL;
|
||||
ALTER TABLE `ipv4_mac` MODIFY `context_name` VARCHAR(128) NOT NULL;
|
Reference in New Issue
Block a user