Merge branch '979-CLI/API-Para-sincronizar-la-metaconsola' into 'develop'

Metaconsole synchronization for api - #979

See merge request artica/pandorafms!1057
This commit is contained in:
vgilc 2017-12-21 11:00:09 +01:00
commit 6ac8571b2d
1 changed files with 28 additions and 0 deletions

View File

@ -10061,4 +10061,32 @@ function api_get_module_graph($id_module, $thrash2, $other, $thrash4) {
}
}
function api_set_metaconsole_synch($keys) {
if (defined('METACONSOLE')) {
$data['keys'] = array('customer_key'=>$keys);
foreach ($data['keys'] as $key => $value) {
db_process_sql_update(
'tupdate_settings',
array(db_escape_key_identifier('value') => $value),
array(db_escape_key_identifier('key') => $key));
}
// Validate update the license in nodes:
enterprise_include_once('include/functions_metaconsole.php');
list ($nodes_failed, $total_nodes) = metaconsole_update_all_nodes_license();
if ($nodes_failed === 0) {
echo __('Metaconsole and all nodes license updated');
}
else {
echo __('Metaconsole license updated but %d of %d node synchronization failed', $nodes_failed, $total_nodes);
}
}
else{
echo __('This function is only for metaconsole');
}
}
?>