diff --git a/LibreNMS/OS/Ocnos.php b/LibreNMS/OS/Ocnos.php index 92c95e8685..7f9246ec80 100644 --- a/LibreNMS/OS/Ocnos.php +++ b/LibreNMS/OS/Ocnos.php @@ -12,7 +12,7 @@ use SnmpQuery; class Ocnos extends OS implements EntityPhysicalDiscovery, TransceiverDiscovery { - private bool $sfpSeen = false; + private ?bool $portBreakoutEnabled = null; private ?Collection $ifNamePortIdMap = null; public function discoverEntityPhysical(): Collection @@ -171,13 +171,8 @@ class Ocnos extends OS implements EntityPhysicalDiscovery, TransceiverDiscovery default => 'ge', }; - // Handle UfiSpace S9600 10G breakout, which is optionally enabled - if ($cmmTransType == 'sfp') { - $this->sfpSeen = true; - } - return match ($this->getDevice()->hardware) { - 'Ufi Space S9600-32X-R' => $prefix . ($this->sfpSeen ? ($cmmTransType == 'qsfp' ? $cmmTransIndex - 5 : $cmmTransIndex - 2) : $cmmTransIndex - 1), + 'Ufi Space S9600-32X-R' => $prefix . ($this->portBreakoutEnabled() ? ($cmmTransType == 'qsfp' ? $cmmTransIndex - 5 : $cmmTransIndex - 2) : $cmmTransIndex - 1), 'Ufi Space S9510-28DC-B' => $prefix . ($cmmTransIndex - 1), 'Ufi Space S9500-30XS-P' => $prefix . ($cmmTransType == 'qsfp' ? $cmmTransIndex - 29 : $cmmTransIndex - 1), 'Edgecore 7316-26XB-O-48V-F' => $prefix . ($cmmTransType == 'qsfp' ? $cmmTransIndex - 1 : $cmmTransIndex - 3), @@ -260,4 +255,17 @@ class Ocnos extends OS implements EntityPhysicalDiscovery, TransceiverDiscovery ]); }); } + + private function portBreakoutEnabled(): bool + { + // Handle UfiSpace S9600 10G breakout, which is optionally enabled + if ($this->portBreakoutEnabled === null) { + // check for xe ports in ifTable + $this->portBreakoutEnabled = $this->getDevice()->ports()->exists() + ? $this->getDevice()->ports()->where('ifName', 'LIKE', 'xe%')->exists() // ports module has run + : str_contains(SnmpQuery::cache()->walk('IF-MIB::ifName')->raw, 'xe'); // no ports in db + } + + return $this->portBreakoutEnabled; + } }