refactor: Centralised the updating of device logo #5873 (#5874)

This commit is contained in:
Neil Lathwood
2017-02-14 12:56:16 +00:00
committed by GitHub
parent 1e2ab73239
commit b4da5de452
4 changed files with 13 additions and 12 deletions

View File

@@ -8,10 +8,4 @@ if ($os != $device['os']) {
echo "Changed OS! : $os\n";
}
$icon = getImageName($device, false);
if ($icon != $device['icon']) {
log_event('Device Icon changed ' . $device['icon'] . " => $icon", $device, 'system', 3);
$device['icon'] = $icon;
$sql = dbUpdate(array('icon' => $icon), 'devices', 'device_id=?', array($device['device_id']));
echo "Changed Icon! : $icon\n";
}
update_device_logo($device);

View File

@@ -1993,3 +1993,14 @@ function recordSnmpStatistic($stat, $start_time)
$snmp_stats["${stat}_sec"] += $runtime;
return $runtime;
}
function update_device_logo($device)
{
$icon = getImageName($device, false);
if ($icon != $device['icon']) {
log_event('Device Icon changed ' . $device['icon'] . " => $icon", $device, 'system', 3);
$device['icon'] = $icon;
$sql = dbUpdate(array('icon' => $icon), 'devices', 'device_id=?', array($device['device_id']));
echo "Changed Icon! : $icon\n";
}
}

View File

@@ -30,10 +30,7 @@ if ($serial != $device['serial']) {
log_event('Serial -> ' . $serial, $device, 'system', 3);
}
if ($icon != $device['icon']) {
$update_array['icon'] = $icon;
log_event('Icon -> ' . $icon, $device, 'system', 3);
}
update_device_logo($device);
echo 'Hardware: ' . $hardware . PHP_EOL;
echo 'Version: ' . $version . PHP_EOL;

View File

@@ -2,7 +2,6 @@
$version = snmp_get($device, 'rndBrgVersion.0', '-Ovq', 'RADLAN-MIB');
$hardware = str_replace('ATI', 'Allied Telesis', $poll_device['sysDescr']);
$icon = 'allied';
$features = snmp_get($device, 'rndBaseBootVersion.00', '-Ovq', 'RADLAN-MIB');