From e2edbcb41619ada4a2b2574cfd9c821da6fdc5bc Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Thu, 14 Oct 2010 15:09:29 +0000 Subject: [PATCH] 2010-10-14 Miguel de Dios * pandoradb.sql, extras/pandoradb_migrate_v3.1_to_v3.2.sql: added in the table "tagente_modulo" the field "policy_adopted" for to set a module pre exist in policy as adopted. *operation/agentes/status_monitor.php, operation/agentes/estado_ultimopaquete.php, operation/agentes/estado_monitores.php, godmode/agentes/module_manager_editor_common.php, godmode/agentes/module_manager.php: show the icon of "adopted" or "adopted but unlinked" in the list of modules. Pending tasks: #3083123 * include/functions_modules.php: cleaned source code style in function "update_agent_module". * godmode/agentes/module_manager_editor_network.php: fixed warning messages when use this file in policies. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3402 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 23 ++++++++++++++++ .../extras/pandoradb_migrate_v3.1_to_v3.2.sql | 1 + .../godmode/agentes/module_manager.php | 26 +++++++++++++++--- .../agentes/module_manager_editor_common.php | 17 +++++++++++- .../agentes/module_manager_editor_network.php | 17 ++++++++++-- pandora_console/include/functions_modules.php | 3 +++ .../operation/agentes/estado_monitores.php | 27 +++++++++++++++---- .../agentes/estado_ultimopaquete.php | 25 ++++++++++++++--- .../operation/agentes/status_monitor.php | 25 ++++++++++++++--- pandora_console/pandoradb.sql | 1 + 10 files changed, 145 insertions(+), 20 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 7d0e58ed2e..0d88b3c857 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,26 @@ +2010-10-14 Miguel de Dios + + * pandoradb.sql, extras/pandoradb_migrate_v3.1_to_v3.2.sql: added in the + table "tagente_modulo" the field "policy_adopted" for to set a module + pre exist in policy as adopted. + + *operation/agentes/status_monitor.php, + operation/agentes/estado_ultimopaquete.php, + operation/agentes/estado_monitores.php, + godmode/agentes/module_manager_editor_common.php, + godmode/agentes/module_manager.php: show the icon of "adopted" or "adopted + but unlinked" in the list of modules. + + Pending tasks: #3083123 + + + + * include/functions_modules.php: cleaned source code style in function + "update_agent_module". + + * godmode/agentes/module_manager_editor_network.php: fixed warning messages + when use this file in policies. + 2010-10-14 Sergio Martin * images/policies_not_brick.png: Added a module-not-policy diff --git a/pandora_console/extras/pandoradb_migrate_v3.1_to_v3.2.sql b/pandora_console/extras/pandoradb_migrate_v3.1_to_v3.2.sql index 4be3555879..eafa119090 100644 --- a/pandora_console/extras/pandoradb_migrate_v3.1_to_v3.2.sql +++ b/pandora_console/extras/pandoradb_migrate_v3.1_to_v3.2.sql @@ -69,6 +69,7 @@ CREATE TABLE IF NOT EXISTS `tnetwork_map` ( ALTER TABLE `tagente_modulo` ADD COLUMN `id_policy_module` INTEGER UNSIGNED NOT NULL DEFAULT 0 AFTER `nombre`; ALTER TABLE `tagente_modulo` ADD COLUMN `policy_linked` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 AFTER `delete_pending`; +ALTER TABLE `tagente_modulo` ADD COLUMN `policy_adopted` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0; -- ----------------------------------------------------- -- Table `talert_template_modules` diff --git a/pandora_console/godmode/agentes/module_manager.php b/pandora_console/godmode/agentes/module_manager.php index 298eaf6704..64f557980d 100644 --- a/pandora_console/godmode/agentes/module_manager.php +++ b/pandora_console/godmode/agentes/module_manager.php @@ -119,6 +119,7 @@ if ($multiple_delete) { } } + // ========================== // MODULE VISUALIZATION TABLE // ========================== @@ -296,13 +297,30 @@ foreach ($modules as $module) { else { $linked = isModuleLinked($module['id_agente_modulo']); + $adopt = false; + if (isModuleAdopt($module['id_agente_modulo'])) { + $adopt = true; + } + if ($linked) { - $img = 'images/policies.png'; - $title = $policyInfo['name_policy']; + if ($adopt) { + $img = 'images/policies_brick.png'; + $title = __('(Adopt) ') . $policyInfo['name_policy']; + } + else { + $img = 'images/policies.png'; + $title = $policyInfo['name_policy']; + } } else { - $img = 'images/unlinkpolicy.png'; - $title = __('(Unlinked) ') . $policyInfo['name_policy']; + if ($adopt) { + $img = 'images/policies_not_brick.png'; + $title = __('(Adopt) (Unlinked) ') . $policyInfo['name_policy']; + } + else { + $img = 'images/unlinkpolicy.png'; + $title = __('(Unlinked) ') . $policyInfo['name_policy']; + } } $data[1] = '' . diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 7c839e3e9a..ef2b303633 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -125,7 +125,22 @@ $table_simple->data[0][2] = __('Disabled'); $table_simple->data[0][3] = print_checkbox ("disabled", 1, $disabled, true); $table_simple->data[1][0] = __('Type').' '.print_help_icon ('module_type', true); -if ($id_agent_module) { + +if (isset($id_agent_module)) { + if ($id_agent_module) { + $edit = false; + } + else { + $edit = true; + } +} +else +{ + //Run into a policy + $edit = true; +} + +if (!$edit) { $table_simple->data[1][1] = ''.get_moduletype_description ($id_module_type).''; } else { diff --git a/pandora_console/godmode/agentes/module_manager_editor_network.php b/pandora_console/godmode/agentes/module_manager_editor_network.php index 37d92cd4e0..3d447e83f1 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_network.php +++ b/pandora_console/godmode/agentes/module_manager_editor_network.php @@ -113,17 +113,30 @@ if ($id_module_type >= 15 && $id_module_type <= 18) { /* SNMP */ $table_advanced->rowstyle['tcp_send'] = 'display: none'; $table_advanced->rowstyle['tcp_receive'] = 'display: none'; -} elseif ($id_module_type >= 8 && $id_module_type <= 11) { +} +elseif ($id_module_type >= 8 && $id_module_type <= 11) { /* TCP or ICMP */ $table_simple->rowstyle['snmp_1'] = 'display: none'; $table_simple->rowstyle['snmp_2'] = 'display: none'; -} elseif (empty ($update_module_id)) { +} +elseif (empty ($update_module_id)) { $table_advanced->rowstyle['tcp_send'] = 'display: none'; $table_advanced->rowstyle['tcp_receive'] = 'display: none'; $table_simple->rowstyle['snmp_1'] = 'display: none'; $table_simple->rowstyle['snmp_2'] = 'display: none'; } +//For a policy +if (!isset($id_agent_module)) { + $snmp3_auth_user = ''; + $snmp3_auth_pass = ''; + $snmp_version = 1; + $snmp3_privacy_method = ''; + $snmp3_privacy_pass = ''; + $snmp3_auth_method = ''; + $snmp3_security_level = ''; +} + $data = array(); $data[0] = __('Auth user'); $data[1] = print_input_text ('snmp3_auth_user', $snmp3_auth_user, '', 15, 60, true); diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index df93415c7b..a01f40237e 100644 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -145,9 +145,12 @@ function delete_agent_module ($id_agent_module) { function update_agent_module ($id, $values, $onlyNoDeletePending = false) { if (! is_array ($values) || empty ($values)) return false; + if (isset ($values['nombre']) && empty ($values['nombre'])) return false; + + if ($onlyNoDeletePending) { return (@process_sql_update ('tagente_modulo', $values, array ('id_agente_modulo' => (int) $id, 'delete_pending' => 0)) !== false); diff --git a/pandora_console/operation/agentes/estado_monitores.php b/pandora_console/operation/agentes/estado_monitores.php index a1f8b84d2b..4e7bb65197 100644 --- a/pandora_console/operation/agentes/estado_monitores.php +++ b/pandora_console/operation/agentes/estado_monitores.php @@ -202,19 +202,36 @@ foreach ($modules as $module) { } if ($isFunctionPolicies !== ENTERPRISE_NOT_HOOK) { - if($module["id_policy_module"] != 0) { + if ($module["id_policy_module"] != 0) { $linked = isModuleLinked($module['id_agente_modulo']); $id_policy = get_db_value_sql('SELECT id_policy FROM tpolicy_modules WHERE id = '.$module["id_policy_module"]); $name_policy = get_db_value_sql('SELECT name FROM tpolicies WHERE id = '.$id_policy); $policyInfo = infoModulePolicy($module["id_policy_module"]); + $adopt = false; + if (isModuleAdopt($module['id_agente_modulo'])) { + $adopt = true; + } + if ($linked) { - $img = 'images/policies.png'; - $title = $name_policy; + if ($adopt) { + $img = 'images/policies_brick.png'; + $title = __('(Adopt) ') . $name_policy; + } + else { + $img = 'images/policies.png'; + $title = $name_policy; + } } else { - $img = 'images/unlinkpolicy.png'; - $title = __('(Unlinked) ') . $name_policy; + if ($adopt) { + $img = 'images/policies_not_brick.png'; + $title = __('(Unlinked) (Adopt) ') . $name_policy; + } + else { + $img = 'images/unlinkpolicy.png'; + $title = __('(Unlinked) ') . $name_policy; + } } $data[1] = '' . diff --git a/pandora_console/operation/agentes/estado_ultimopaquete.php b/pandora_console/operation/agentes/estado_ultimopaquete.php index c04e2bda68..b8bbb16330 100644 --- a/pandora_console/operation/agentes/estado_ultimopaquete.php +++ b/pandora_console/operation/agentes/estado_ultimopaquete.php @@ -226,13 +226,30 @@ foreach ($modules as $module) { $name_policy = get_db_value_sql('SELECT name FROM tpolicies WHERE id = '.$id_policy); $policyInfo = infoModulePolicy($module["id_policy_module"]); + $adopt = false; + if (isModuleAdopt($module['id_agente_modulo'])) { + $adopt = true; + } + if ($linked) { - $img = 'images/policies.png'; - $title = $name_policy; + if ($adopt) { + $img = 'images/policies_brick.png'; + $title = __('(Adopt) ') . $name_policy; + } + else { + $img = 'images/policies.png'; + $title = $name_policy; + } } else { - $img = 'images/unlinkpolicy.png'; - $title = __('(Unlinked) ') . $name_policy; + if ($adopt) { + $img = 'images/policies_not_brick.png'; + $title = __('(Unlinked) (Adopt) ') . $name_policy; + } + else { + $img = 'images/unlinkpolicy.png'; + $title = __('(Unlinked) ') . $name_policy; + } } echo ""; diff --git a/pandora_console/operation/agentes/status_monitor.php b/pandora_console/operation/agentes/status_monitor.php index 974310294c..0ca8fe2d83 100644 --- a/pandora_console/operation/agentes/status_monitor.php +++ b/pandora_console/operation/agentes/status_monitor.php @@ -223,13 +223,30 @@ foreach ($result as $row) { else { $linked = isModuleLinked($row['id_agente_modulo']); + $adopt = false; + if (isModuleAdopt($row['id_agente_modulo'])) { + $adopt = true; + } + if ($linked) { - $img = 'images/policies.png'; - $title = $policyInfo['name_policy']; + if ($adopt) { + $img = 'images/policies_brick.png'; + $title = __('(Adopt) ') . $policyInfo['name_policy']; + } + else { + $img = 'images/policies.png'; + $title = $policyInfo['name_policy']; + } } else { - $img = 'images/unlinkpolicy.png'; - $title = __('(Unlinked) ') . $policyInfo['name_policy']; + if ($adopt) { + $img = 'images/policies_not_brick.png'; + $title = __('(Unlinked) (Adopt) ') . $policyInfo['name_policy']; + } + else { + $img = 'images/unlinkpolicy.png'; + $title = __('(Unlinked) ') . $policyInfo['name_policy']; + } } $data[0] = '' . diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index 2b0b071ecc..eea2199bf3 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -177,6 +177,7 @@ CREATE TABLE IF NOT EXISTS `tagente_modulo` ( `min_ff_event` int(4) unsigned default '0', `delete_pending` int(1) unsigned default 0, `policy_linked` tinyint(1) unsigned not null default 0, + `policy_adopted` tinyint(1) unsigned not null default 0, `custom_string_1` text default '', `custom_string_2` text default '', `custom_string_3` text default '',