mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
New device:add code (#13842)
* New device:add code pre-requisite for updating other code paths includes option to set display name separate validation code from device creation * remove duplicate community and v3 creds * style fixes * some lint fixes * fix phpstan * Exception cleanup improved messages and translations * port association mode to enum well, pseudo enum * defaults and cleanups * fixed/improved validation messages * fix tests * fix stupid ide refactor mistake * lint fixes
This commit is contained in:
@@ -651,47 +651,6 @@ function format_hostname($device): string
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return valid port association modes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_port_assoc_modes()
|
||||
{
|
||||
return [
|
||||
1 => 'ifIndex',
|
||||
2 => 'ifName',
|
||||
3 => 'ifDescr',
|
||||
4 => 'ifAlias',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get DB id of given port association mode name
|
||||
*
|
||||
* @param string $port_assoc_mode
|
||||
* @return int
|
||||
*/
|
||||
function get_port_assoc_mode_id($port_assoc_mode)
|
||||
{
|
||||
$modes = array_flip(get_port_assoc_modes());
|
||||
|
||||
return isset($modes[$port_assoc_mode]) ? $modes[$port_assoc_mode] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name of given port association_mode ID
|
||||
*
|
||||
* @param int $port_assoc_mode_id Port association mode ID
|
||||
* @return bool
|
||||
*/
|
||||
function get_port_assoc_mode_name($port_assoc_mode_id)
|
||||
{
|
||||
$modes = get_port_assoc_modes();
|
||||
|
||||
return isset($modes[$port_assoc_mode_id]) ? $modes[$port_assoc_mode_id] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query all ports of the given device (by ID) and build port array and
|
||||
* port association maps for ifIndex, ifName, ifDescr. Query port stats
|
||||
|
Reference in New Issue
Block a user