2016-02-01 12:55:35 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Pandora FMS - http://pandorafms.com
|
|
|
|
// ==================================================
|
|
|
|
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
|
|
|
// Please see http://pandorafms.org for full contribution list
|
|
|
|
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation; version 2
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @package Include
|
|
|
|
* @subpackage Migration
|
|
|
|
*/
|
|
|
|
|
2016-02-01 15:12:21 +01:00
|
|
|
require_once("include/functions_maps.php");
|
|
|
|
|
2016-02-01 12:55:35 +01:00
|
|
|
function migration_open_networkmaps() {
|
2016-02-01 15:12:21 +01:00
|
|
|
$old_networkmaps_open = db_get_all_rows_in_table("tnetwork_map");
|
|
|
|
|
2016-02-02 15:49:22 +01:00
|
|
|
html_debug($old_networkmaps_open);
|
2016-02-01 12:55:35 +01:00
|
|
|
|
2016-02-01 15:12:21 +01:00
|
|
|
foreach ($old_networkmaps_open as $old_netw_open) {
|
|
|
|
$new_networkmap = array();
|
|
|
|
|
2016-02-10 14:01:10 +01:00
|
|
|
$new_networkmap['name'] =
|
|
|
|
io_safe_output($old_netw_open['name']);
|
2016-02-01 15:12:21 +01:00
|
|
|
$new_networkmap['id_user'] = $old_netw_open['id_user'];
|
2016-02-10 14:01:10 +01:00
|
|
|
$new_networkmap['id_group'] = $old_netw_open['store_group'];
|
2016-02-01 15:12:21 +01:00
|
|
|
|
2016-02-02 15:49:22 +01:00
|
|
|
switch ($old_netw_open['type']) {
|
|
|
|
case 'radial_dynamic':
|
|
|
|
$new_networkmap['type'] = MAP_TYPE_NETWORKMAP;
|
|
|
|
$new_networkmap['subtype'] = MAP_SUBTYPE_RADIAL_DYNAMIC;
|
|
|
|
break;
|
|
|
|
case 'policies':
|
|
|
|
$new_networkmap['type'] = MAP_TYPE_NETWORKMAP;
|
|
|
|
$new_networkmap['subtype'] = MAP_SUBTYPE_POLICIES;
|
|
|
|
break;
|
|
|
|
case 'groups':
|
|
|
|
$new_networkmap['type'] = MAP_TYPE_NETWORKMAP;
|
|
|
|
$new_networkmap['subtype'] = MAP_SUBTYPE_GROUPS;
|
|
|
|
break;
|
2016-02-01 15:12:21 +01:00
|
|
|
case 'topology':
|
|
|
|
$new_networkmap['type'] = MAP_TYPE_NETWORKMAP;
|
|
|
|
$new_networkmap['subtype'] = MAP_SUBTYPE_TOPOLOGY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-02-12 14:19:31 +01:00
|
|
|
// ---- Source -------------------------------------------------
|
|
|
|
$new_networkmap['source'] = MAP_SOURCE_GROUP;
|
|
|
|
$new_networkmap['source_data'] = $old_netw_open['id_group'];
|
2016-02-10 14:01:10 +01:00
|
|
|
|
2016-02-01 15:12:21 +01:00
|
|
|
switch ($old_netw_open['layout']) {
|
|
|
|
case 'radial':
|
|
|
|
$new_networkmap['generation_method'] = MAP_GENERATION_RADIAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-12 14:19:31 +01:00
|
|
|
// ---- Filter -------------------------------------------------
|
2016-02-01 15:12:21 +01:00
|
|
|
$filter = array();
|
|
|
|
|
2016-02-12 14:19:31 +01:00
|
|
|
$filter['id_tag'] = 0;
|
|
|
|
if ($old_netw_open['id_tag']) {
|
|
|
|
$filter['id_tag'] = 1;
|
2016-02-01 15:12:21 +01:00
|
|
|
}
|
2016-02-12 14:19:31 +01:00
|
|
|
$filter['text'] = $old_netw_open['text_filter'];
|
|
|
|
$filter['show_pandora_nodes'] = 0; // Only metaconsole
|
2016-02-15 12:15:16 +01:00
|
|
|
switch ($old_netw_open['depth']) {
|
2016-02-12 14:19:31 +01:00
|
|
|
case 'agents':
|
|
|
|
$filter['show_modules'] = 0;
|
|
|
|
$filter['show_agents'] = 1;
|
|
|
|
break;
|
|
|
|
case 'all':
|
|
|
|
$filter['show_modules'] = 1;
|
|
|
|
$filter['show_agents'] = 1;
|
|
|
|
break;
|
|
|
|
case 'groups':
|
|
|
|
$filter['show_modules'] = 0;
|
|
|
|
$filter['show_agents'] = 0;
|
|
|
|
break;
|
2016-02-01 15:12:21 +01:00
|
|
|
}
|
2016-02-12 14:19:31 +01:00
|
|
|
$filter['only_modules_with_alerts'] = 0;
|
2016-02-01 15:12:21 +01:00
|
|
|
if ($old_netw_open['only_modules_with_alerts']) {
|
2016-02-12 14:19:31 +01:00
|
|
|
$filter['only_modules_with_alerts'] = 1;
|
2016-02-01 15:12:21 +01:00
|
|
|
}
|
|
|
|
$filter['show_module_group'] = 0;
|
|
|
|
if ($old_netw_open['show_modulegroup']) {
|
|
|
|
$filter['show_module_group'] = 1;
|
|
|
|
}
|
2016-02-12 14:19:31 +01:00
|
|
|
$filter['module_group'] = 0;
|
|
|
|
if ($old_netw_open['id_module_group']) {
|
|
|
|
$filter['module_group'] = 1;
|
|
|
|
}
|
|
|
|
$filter['only_policy_modules'] = 0;
|
|
|
|
$filter['only_snmp_modules'] = 0;
|
|
|
|
if ($old_netw_open['show_snmp_modules']) {
|
|
|
|
$filter['only_snmp_modules'] = 1;
|
2016-02-01 15:12:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$new_networkmap['filter'] = json_encode($filter);
|
2016-02-12 14:19:31 +01:00
|
|
|
// -------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2016-02-01 15:12:21 +01:00
|
|
|
|
|
|
|
html_debug($new_networkmap);
|
|
|
|
|
2016-02-02 15:49:22 +01:00
|
|
|
maps_save_map($new_networkmap);
|
2016-02-01 15:12:21 +01:00
|
|
|
}
|
2016-02-01 12:55:35 +01:00
|
|
|
}
|
|
|
|
?>
|