mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-26 00:18:03 +02:00
Merge pull request #1811 from laf/issue-1689
Ability to override the ports ifAlias
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* LibreNMS
|
||||
*
|
||||
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or (at your
|
||||
* option) any later version. Please see LICENSE.txt at the top level of
|
||||
* the source code distribution for details.
|
||||
*/
|
||||
|
||||
$status = 'error';
|
||||
|
||||
$descr = mres($_POST['descr']);
|
||||
$device_id = mres($_POST['device_id']);
|
||||
$ifName = mres($_POST['ifName']);
|
||||
$port_id = mres($_POST['port_id']);
|
||||
|
||||
logfile($descr . ','. $device_id . ','. $ifName. ','. $port_id);
|
||||
|
||||
if (!empty($ifName) && is_numeric($port_id)) {
|
||||
// We have ifName and port id so update ifAlias
|
||||
if (empty($descr)) {
|
||||
$descr = 'repoll';
|
||||
// Set to repoll so we avoid using ifDescr on port poll
|
||||
}
|
||||
if (dbUpdate(array('ifAlias'=>$descr), 'ports', '`port_id`=?', array($port_id)) > 0) {
|
||||
$device = device_by_id_cache($device_id);
|
||||
if ($descr === 'repoll') {
|
||||
del_dev_attrib($device, 'ifName');
|
||||
}
|
||||
else {
|
||||
set_dev_attrib($device, 'ifName', $ifName);
|
||||
}
|
||||
$status = 'ok';
|
||||
}
|
||||
else {
|
||||
$status = 'na';
|
||||
}
|
||||
}
|
||||
|
||||
$response = array(
|
||||
'status' => $status,
|
||||
);
|
||||
echo _json_encode($response);
|
||||
@@ -64,7 +64,7 @@ foreach (dbFetchRows($sql, $param) as $port) {
|
||||
<input type="hidden" name="olddis_'.$port['port_id'].'" value="'.($port['disabled'] ? 1 : 0).'"">',
|
||||
'ignore' => '<input type="checkbox" class="ignore-check" name="ignore_'.$port['port_id'].'"'.($port['ignore'] ? 'checked' : '').'>
|
||||
<input type="hidden" name="oldign_'.$port['port_id'].'" value="'.($port['ignore'] ? 1 : 0).'"">',
|
||||
'ifAlias' => $port['ifAlias']
|
||||
'ifAlias' => '<div class="form-group"><input class="form-control input-sm" id="if-alias" name="if-alias" data-device_id="'.$port['device_id'].'" data-port_id="'.$port['port_id'].'" data-ifName="'.$port['ifName'].'" value="'.$port['ifAlias'].'"><span class="glyphicon form-control-feedback" aria-hidden="true"></span></div>'
|
||||
);
|
||||
|
||||
}//end foreach
|
||||
@@ -75,4 +75,4 @@ $output = array(
|
||||
'rows' => $response,
|
||||
'total' => $total,
|
||||
);
|
||||
echo _json_encode($output);
|
||||
echo _json_encode($output);
|
||||
|
||||
Reference in New Issue
Block a user