fix: os type and group not being set (#5357)

This commit is contained in:
Tony Murray
2017-01-09 02:16:09 -06:00
committed by Neil Lathwood
parent 5ad8fd3c0c
commit b3f6218359
5 changed files with 34 additions and 32 deletions

View File

@@ -1509,16 +1509,32 @@ function display($value)
}
/**
* @param $os
* @return array|mixed
* Load the os definition for the device and set type and os_group
* $device['os'] must be set
*
* @param array $device
* @throws Exception No OS to load
*/
function load_os($os)
function load_os(&$device)
{
global $config;
if (isset($os)) {
return Symfony\Component\Yaml\Yaml::parse(
file_get_contents($config['install_dir'] . '/includes/definitions/' . $os . '.yaml')
);
if (!isset($device['os'])) {
throw new Exception('No OS to load');
}
$config['os'][$device['os']] = Symfony\Component\Yaml\Yaml::parse(
file_get_contents($config['install_dir'] . '/includes/definitions/' . $device['os'] . '.yaml')
);
// Set type to a predefined type for the OS if it's not already set
if ($device['type'] == 'unknown' || $device['type'] == '') {
if ($config['os'][$device['os']]['type']) {
$device['type'] = $config['os'][$device['os']]['type'];
}
}
if ($config['os'][$device['os']]['group']) {
$device['os_group'] = $config['os'][$device['os']]['group'];
}
}