mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Reject API device_add that are missing snmp info (#16314)
This commit is contained in:
@@ -167,6 +167,30 @@ class Device extends BaseModel
|
||||
return null;
|
||||
}
|
||||
|
||||
public function hasSnmpInfo(): bool
|
||||
{
|
||||
if ($this->snmpver == 'v3') {
|
||||
if ($this->authlevel == 'authNoPriv') {
|
||||
return ! empty($this->authname) && ! empty($this->authpass);
|
||||
}
|
||||
|
||||
if ($this->authlevel == 'authPriv') {
|
||||
return ! empty($this->authname)
|
||||
&& ! empty($this->authpass)
|
||||
&& ! empty($this->cryptoalgo)
|
||||
&& ! empty($this->cryptopass);
|
||||
}
|
||||
|
||||
return $this->authlevel !== 'noAuthNoPriv'; // reject if not noAuthNoPriv
|
||||
}
|
||||
|
||||
if ($this->snmpver == 'v2c' || $this->snmpver == 'v1') {
|
||||
return ! empty($this->community);
|
||||
}
|
||||
|
||||
return false; // no known snmpver
|
||||
}
|
||||
|
||||
/**
|
||||
* Get VRF contexts to poll.
|
||||
* If no contexts are found, return the default context ''
|
||||
|
Reference in New Issue
Block a user