mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Use Exceptions
Use exceptions for addHost() Gets rid of silly mixed return and only returns the device_id. Throwing an exception if we run into any issues. Slightly modifies api add host output again to include device_id
This commit is contained in:
@@ -289,14 +289,13 @@ function add_device() {
|
||||
$message = "You haven't specified an SNMP version to use";
|
||||
}
|
||||
if (empty($message)) {
|
||||
$result = addHost($hostname, $snmpver, $port, $transport, 1, $poller_group, $force_add);
|
||||
if (is_numeric($result)) {
|
||||
try {
|
||||
$device_id = addHost($hostname, $snmpver, $port, $transport, $poller_group, $force_add);
|
||||
$code = 201;
|
||||
$status = 'ok';
|
||||
$message = "Device $hostname has been added successfully";
|
||||
}
|
||||
else {
|
||||
$message = $result;
|
||||
$message = "Device $hostname ($device_id) has been added successfully";
|
||||
} catch (Exception $e) {
|
||||
$message = $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user