fix: better Cisco hardware formatting (#5184)

This commit is contained in:
Tony Murray
2016-12-16 17:04:37 -06:00
committed by Neil Lathwood
parent bcae14c7d9
commit 9fef312a20

View File

@@ -759,18 +759,22 @@ function formatCiscoHardware(&$device, $short = false)
{
if ($device['os'] == "ios") {
if ($device['hardware']) {
if (preg_match("/^WS-C([A-Za-z0-9]+).*/", $device['hardware'], $matches)) {
if (preg_match("/^WS-C([A-Za-z0-9]+)/", $device['hardware'], $matches)) {
if (!$short) {
$device['hardware'] = "Catalyst " . $matches[1] . " (" . $device['hardware'] . ")";
} else {
$device['hardware'] = "Catalyst " . $matches[1];
}
} elseif (preg_match("/^CISCO([0-9]+)(.*)/", $device['hardware'], $matches)) {
if (!$short && $matches[2]) {
$device['hardware'] = "Cisco " . $matches[1] . " (" . $device['hardware'] . ")";
} else {
$device['hardware'] = "Cisco " . $matches[1];
}
} elseif (preg_match("/^CISCO([0-9]+)$/", $device['hardware'], $matches)) {
$device['hardware'] = "Cisco " . $matches[1];
}
} else {
if (preg_match("/Cisco IOS Software, C([A-Za-z0-9]+) Software.*/", $device['sysDescr'], $matches)) {
$device['hardware'] = "Cisco " . $matches[1];
$device['hardware'] = "Catalyst " . $matches[1];
} elseif (preg_match("/Cisco IOS Software, ([0-9]+) Software.*/", $device['sysDescr'], $matches)) {
$device['hardware'] = "Cisco " . $matches[1];
}