mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Correctly set error code for missing SNMP version
This commit is contained in:
@@ -326,6 +326,7 @@ function list_devices()
|
|||||||
function add_device()
|
function add_device()
|
||||||
{
|
{
|
||||||
// This will add a device using the data passed encoded with json
|
// This will add a device using the data passed encoded with json
|
||||||
|
// FIXME: Execution flow through this function could be improved
|
||||||
global $config;
|
global $config;
|
||||||
$app = \Slim\Slim::getInstance();
|
$app = \Slim\Slim::getInstance();
|
||||||
$data = json_decode(file_get_contents('php://input'), true);
|
$data = json_decode(file_get_contents('php://input'), true);
|
||||||
@@ -368,15 +369,17 @@ function add_device()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$code = 400;
|
||||||
|
$status = "error";
|
||||||
$message = "You haven't specified an SNMP version to use";
|
$message = "You haven't specified an SNMP version to use";
|
||||||
}
|
}
|
||||||
$code = 201;
|
|
||||||
if(empty($message))
|
if(empty($message))
|
||||||
{
|
{
|
||||||
require_once("../includes/functions.php");
|
require_once("../includes/functions.php");
|
||||||
$result = addHost($hostname, $snmpver, $port, $transport, 1);
|
$result = addHost($hostname, $snmpver, $port, $transport, 1);
|
||||||
if($result)
|
if($result)
|
||||||
{
|
{
|
||||||
|
$code = 201;
|
||||||
$status = "ok";
|
$status = "ok";
|
||||||
$message = "Device $hostname has been added successfully";
|
$message = "Device $hostname has been added successfully";
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user