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:
Tony Murray
2022-03-12 16:14:32 -06:00
committed by GitHub
parent 6d3bf03074
commit 1bfd411995
27 changed files with 803 additions and 389 deletions

View File

@@ -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