Fix regression on HW discovery for Cisco Catalyst chassis (#10877)

* Catalyst fix for HW

* Try to avoid issue with stacks, chassis or standalone boxes

* formatCiscoHardware iosxe for humans

* codeclimate
This commit is contained in:
PipoCanaja
2019-11-24 02:17:00 +01:00
committed by Tony Murray
parent ef562f607e
commit 1ab645c75c
3 changed files with 17 additions and 7 deletions

View File

@ -193,6 +193,18 @@ class Rewrite
}
}
if ($device['os'] == "iosxe") {
if ($device['hardware']) {
if (preg_match('/CAT9K/', $device['sysDescr'], $matches) && preg_match("/^C(9[A-Za-z0-9]+)/", $device['hardware'], $matches2)) {
if (!$short) {
$device['hardware'] = "Catalyst " . $matches2[1] . " (" . $device['hardware'] . ")";
} else {
$device['hardware'] = "Catalyst " . $matches2[1];
}
}
}
}
return $device['hardware'];
}

View File

@ -26,7 +26,7 @@ echo '<script src="js/L.Control.Locate.min.js"></script>';
$uptime = (Time::formatInterval($device['status'] ? $device['uptime'] : time() - strtotime($device['last_polled'])));
$uptime_text = ($device['status'] ? 'Uptime' : 'Downtime');
if ($device['os'] == 'ios') {
if ($device['os'] == 'ios' || $device['os'] == 'iosxe') {
formatCiscoHardware($device);
}

View File

@ -28,23 +28,21 @@ if ($data[1]['entPhysicalContainedIn'] == '0') {
if (!empty($data[1]['entPhysicalSoftwareRev'])) {
$version = $data[1]['entPhysicalSoftwareRev'];
}
if (!empty($data[1]['entPhysicalName'])) {
$hardware = $data[1]['entPhysicalName'];
}
if (!empty($data[1]['entPhysicalModelName'])) {
$hardware = $data[1]['entPhysicalModelName'];
}
}
if (!empty($data[1000]['entPhysicalModelName'])) {
if (empty($hardware) && !empty($data[1000]['entPhysicalModelName'])) {
$hardware = $data[1000]['entPhysicalModelName'];
} elseif (!empty($data[1000]['entPhysicalContainedIn'])) {
} elseif (empty($hardware) && !empty($data[1000]['entPhysicalContainedIn'])) {
$hardware = $data[$data[1000]['entPhysicalContainedIn']]['entPhysicalName'];
} elseif (!empty($data[1001]['entPhysicalModelName'])) {
} elseif ((preg_match('/stack/i', $hardware) || empty($hardware)) && !empty($data[1001]['entPhysicalModelName'])) {
$hardware = $data[1001]['entPhysicalModelName'];
} elseif (!empty($data[1001]['entPhysicalContainedIn'])) {
} elseif (empty($hardware) && !empty($data[1001]['entPhysicalContainedIn'])) {
$hardware = $data[$data[1001]['entPhysicalContainedIn']]['entPhysicalName'];
}