|
11 | 11 | echo ' Brocade FDP: '; |
12 | 12 | $fdp_array = SnmpQuery::hideMib()->walk('FOUNDRY-SN-SWITCH-GROUP-MIB::snFdpCacheEntry')->table(2); |
13 | 13 |
|
14 | | - foreach ($fdp_array as $key => $fdp_if_array) { |
15 | | - $interface = get_port_by_ifIndex($device['device_id'], $key); |
| 14 | + foreach ($fdp_array as $ifIndex => $fdp_if_array) { |
| 15 | + $interface = \App\Facades\PortCache::getByIfIndex($ifIndex, $device['device_id']); |
16 | 16 | d_echo($fdp_if_array); |
17 | 17 |
|
18 | 18 | foreach ($fdp_if_array as $fdp) { |
|
28 | 28 |
|
29 | 29 | $remote_port_id = find_port_id($fdp['snFdpCacheDevicePort'], '', $remote_device_id); |
30 | 30 | discover_link( |
31 | | - $interface['port_id'], |
| 31 | + $interface->port_id, |
32 | 32 | $fdp['snFdpCacheVendorId'], |
33 | 33 | $remote_port_id, |
34 | 34 | $fdp['snFdpCacheDeviceId'], |
|
47 | 47 | echo ' CISCO-CDP-MIB: '; |
48 | 48 | $cdp_array = SnmpQuery::hideMib()->walk('CISCO-CDP-MIB::cdpCache')->table(2); |
49 | 49 |
|
50 | | - foreach ($cdp_array as $key => $cdp_if_array) { |
51 | | - $interface = get_port_by_ifIndex($device['device_id'], $key); |
| 50 | + foreach ($cdp_array as $ifIndex => $cdp_if_array) { |
| 51 | + $interface = PortCache::getByIfIndex($ifIndex, $device['device_id']); |
52 | 52 |
|
53 | 53 | foreach ($cdp_if_array as $cdp) { |
54 | 54 | d_echo($cdp); |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 |
|
79 | | - if ($interface['port_id'] && $cdp['cdpCacheDeviceId'] && $cdp['cdpCacheDevicePort']) { |
| 79 | + if ($interface?->port_id && $cdp['cdpCacheDeviceId'] && $cdp['cdpCacheDevicePort']) { |
80 | 80 | $remote_port_id = find_port_id($cdp['cdpCacheDevicePort'], '', $remote_device_id); |
81 | 81 | discover_link( |
82 | | - $interface['port_id'], |
| 82 | + $interface->port_id, |
83 | 83 | 'cdp', |
84 | 84 | $remote_port_id, |
85 | 85 | $cdp['cdpCacheDeviceId'], |
|
153 | 153 | foreach ($lldp_array as $lldp_array_inner) { |
154 | 154 | foreach ($lldp_array_inner as $lldp) { |
155 | 155 | d_echo($lldp); |
156 | | - $interface = get_port_by_ifIndex($device['device_id'], $lldp['lldpRemLocalPortNum'] ?? null); |
| 156 | + $interface = PortCache::getByIfIndex($lldp['lldpRemLocalPortNum'] ?? null, $device['device_id']); |
157 | 157 | $remote_device_id = find_device_id($lldp['lldpRemSysName'] ?? null); |
158 | 158 |
|
159 | 159 | if (LibrenmsConfig::get('autodiscovery.xdp') && isset($lldp['lldpRemSysName']) && ! $remote_device_id && |
|
163 | 163 | $remote_device_id = discover_new_device($lldp['lldpRemSysName'], $device, 'LLDP', $interface); |
164 | 164 | } |
165 | 165 |
|
166 | | - if (is_array($interface) && $interface['port_id'] && $lldp['lldpRemSysName'] && $lldp['lldpRemPortId']) { |
| 166 | + if ($interface?->port_id && $lldp['lldpRemSysName'] && $lldp['lldpRemPortId']) { |
167 | 167 | $remote_port_id = find_port_id($lldp['lldpRemPortDesc'], $lldp['lldpRemPortId'], $remote_device_id); |
168 | 168 | discover_link( |
169 | | - $interface['port_id'], |
| 169 | + $interface->port_id, |
170 | 170 | 'lldp', |
171 | 171 | $remote_port_id, |
172 | 172 | $lldp['lldpRemSysName'], |
|
187 | 187 | foreach ($sub_lldp_1 as $ifIndex => $sub_lldp_2) { |
188 | 188 | foreach ($sub_lldp_2 as $sub_lldp_3) { |
189 | 189 | foreach ($sub_lldp_3 as $lldp) { |
190 | | - $interface = get_port_by_ifIndex($device['device_id'], $ifIndex); |
| 190 | + $interface = PortCache::getByIfIndex($ifIndex, $device['device_id']); |
191 | 191 | $remote_device_id = find_device_id($lldp['tmnxLldpRemSysName']); |
192 | 192 |
|
193 | 193 | if (! $remote_device_id && |
|
198 | 198 | $remote_device_id = discover_new_device($lldp['tmnxLldpRemSysName'], $device, 'LLDP', $interface); |
199 | 199 | } |
200 | 200 |
|
201 | | - if ($interface['port_id'] && $lldp['tmnxLldpRemSysName'] && $lldp['tmnxLldpRemPortId']) { |
| 201 | + if ($interface?->port_id && $lldp['tmnxLldpRemSysName'] && $lldp['tmnxLldpRemPortId']) { |
202 | 202 | $remote_port_id = find_port_id($lldp['tmnxLldpRemPortDesc'], $lldp['tmnxLldpRemPortId'], $remote_device_id); |
203 | 203 | discover_link( |
204 | | - $interface['port_id'], |
| 204 | + $interface->port_id, |
205 | 205 | 'lldp', |
206 | 206 | $remote_port_id, |
207 | 207 | $lldp['tmnxLldpRemSysName'], |
|
229 | 229 | continue; |
230 | 230 | } |
231 | 231 |
|
232 | | - $interface = get_port_by_ifIndex($device['device_id'], $IndexId); |
233 | | - if (! $interface['port_id']) { |
| 232 | + $interface = PortCache::getByIfIndex($IndexId, $device['device_id']); |
| 233 | + if (empty($interface->port_id)) { |
234 | 234 | $local_ifName = $lldp['lldpNeighborPortId'][$IndexId][1]; |
235 | 235 | $local_port_id = find_port_id('gigabitEthernet ' . $local_ifName, null, $device['device_id']); |
236 | | - $interface = get_port_by_id($local_port_id); |
| 236 | + $interface = PortCache::get($local_port_id); |
237 | 237 | } |
238 | 238 |
|
239 | 239 | $remote_device_id = find_device_id($lldp['lldpNeighborDeviceName'][$IndexId][1]); |
|
250 | 250 | $remote_device_id = discover_new_device($remote_device_name, $device, 'LLDP', $interface); |
251 | 251 | } |
252 | 252 |
|
253 | | - if ($interface['port_id'] && $remote_device_name && $remote_port_descr) { |
| 253 | + if ($interface?->port_id && $remote_device_name && $remote_port_descr) { |
254 | 254 | discover_link( |
255 | | - $interface['port_id'], //our port id from database |
| 255 | + $interface->port_id, //our port id from database |
256 | 256 | 'lldp', |
257 | 257 | $remote_port_id, //remote port id from database if applicable |
258 | 258 | $remote_device_name, //remote device name from SNMP walk |
|
0 commit comments