diff --git a/pandora_console/extras/mr/50.sql b/pandora_console/extras/mr/50.sql index ca1886737d..0ab1cb6387 100644 --- a/pandora_console/extras/mr/50.sql +++ b/pandora_console/extras/mr/50.sql @@ -20,4 +20,108 @@ INSERT INTO `treport_content` (id_report, id_gs, id_agent_module, type, period, INSERT INTO `treport_content_item` (id_report_content, id_agent_module, id_agent_module_failover, operation, server_name) SELECT id_rc, id_agent_module, 0, '', server_name FROM treport_content WHERE type = 'availability' AND id_agent <> 0 AND id_agent_module <> 0; DELETE FROM `treport_content` WHERE type = 'histogram_data'; +ALTER TABLE `tperfil` ADD COLUMN `network_config_view`tinyint(1) NOT NULL DEFAULT 0; +ALTER TABLE `tperfil` ADD COLUMN `network_config_edit`tinyint(1) NOT NULL DEFAULT 0; +ALTER TABLE `tperfil` ADD COLUMN `network_config_management`tinyint(1) NOT NULL DEFAULT 0; + +CREATE TABLE IF NOT EXISTS `tncm_vendor` ( + `id` serial, + `name` varchar(255) UNIQUE, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `tncm_model` ( + `id` serial, + `id_vendor` bigint(20) unsigned NOT NULL, + `name` varchar(255) UNIQUE, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_vendor`) REFERENCES `tncm_vendor`(`id`) ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `tncm_template` ( + `id` serial, + `name` text, + `vendors` text, + `models` text, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `tncm_script` ( + `id` serial, + `type` int unsigned not null default 0, + `content` text, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `tncm_template_scripts` ( + `id` serial, + `id_template` bigint(20) unsigned NOT NULL, + `id_script` bigint(20) unsigned NOT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_template`) REFERENCES `tncm_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `tncm_agent` ( + `id_agent` int(10) unsigned NOT NULL, + `id_vendor` bigint(20) unsigned, + `id_model` bigint(20) unsigned, + `protocol` int unsigned not null default 0, + `cred_key` varchar(100), + `adv_key` varchar(100), + `port` int(4) unsigned default 22, + `status` int(4) NOT NULL default 5, + `updated_at` bigint(20) NOT NULL default 0, + `config_backup_id` bigint(20) UNSIGNED DEFAULT NULL, + `id_template` bigint(20) unsigned, + `execute_type` int(2) UNSIGNED NOT NULL default 0, + `execute` int(2) UNSIGNED NOT NULL default 0, + `last_error` text, + PRIMARY KEY (`id_agent`), + FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`cred_key`) REFERENCES `tcredential_store`(`identifier`) ON UPDATE CASCADE ON DELETE SET NULL, + FOREIGN KEY (`id_template`) REFERENCES `tncm_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_vendor`) REFERENCES `tncm_vendor`(`id`) ON UPDATE CASCADE ON DELETE SET NULL, + FOREIGN KEY (`id_model`) REFERENCES `tncm_model`(`id`) ON UPDATE CASCADE ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE IF NOT EXISTS `tncm_agent_data` ( + `id` serial, + `id_agent` int(10) unsigned NOT NULL, + `script_type` int unsigned not null, + `data` LONGBLOB, + `status` int(4) NOT NULL default 5, + `updated_at` bigint(20) NOT NULL default 0, + FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT IGNORE INTO `tncm_vendor` VALUES + (1,'Cisco'), + (2, 'D-Link Systems, Inc.'), + (3, 'MikroTik'), + (4, 'Alcatel-Lucent Enterprise'), + (5, 'Ubiquiti Networks, Inc.'), + (6, 'Allied Telesis, Inc.'), + (7, 'Frogfoot Networks'), + (8, 'IBM'), + (9, 'Dell Inc.'), + (10, 'Hitachi Communication Technologies, Ltd.'), + (11, 'Netlink'), + (12, 'Ascom'), + (13, 'Synology Inc.'), + (14, 'Fujitsu Network Communications, Inc.'); + +INSERT IGNORE INTO `tncm_model` VALUES (1,1,'7200'); + +INSERT IGNORE INTO `tncm_template` VALUES (1,'cisco-base','[\"1\"]','[\"1\"]'); + +INSERT IGNORE INTO `tncm_script` VALUES + (1,0,'enable expect:Password:\s* _enablepass_ exit'), + (2,1,'enable expect:Password:\s* _enablepass_ term length 0 capture:show running-config exit '), + (3,2,'enable expect:Password:\s* _enablepass_ term length 0 config terminal _applyconfigbackup_ exit '), + (4,3,'enable expect:Password:\s* _enablepass_ term length 0 capture:show version | i IOS Software exit '), + (5,5,'enable expect:Password:\s* _enablepass_ term length 0 config term end end exit '); + +INSERT INTO `tncm_template_scripts`(`id_template`, `id_script`) VALUES (1,1),(1,2),(1,3),(1,4),(1,5); + COMMIT; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index b30162f256..b5e340c1dc 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -4079,6 +4079,10 @@ ALTER TABLE `tperfil` DROP COLUMN `incident_view`; ALTER TABLE `tperfil` DROP COLUMN `incident_edit`; ALTER TABLE `tperfil` DROP COLUMN `incident_management`; +ALTER TABLE `tperfil` ADD COLUMN `network_config_view`tinyint(1) NOT NULL DEFAULT 0; +ALTER TABLE `tperfil` ADD COLUMN `network_config_edit`tinyint(1) NOT NULL DEFAULT 0; +ALTER TABLE `tperfil` ADD COLUMN `network_config_management`tinyint(1) NOT NULL DEFAULT 0; + -- ----------------------------------------------------- -- Table `talert_execution_queue` -- ----------------------------------------------------- @@ -4092,4 +4096,126 @@ CREATE TABLE IF NOT EXISTS `talert_execution_queue` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -UPDATE `tlanguage` SET `name` = 'Deutsch' WHERE `id_language` = 'de'; \ No newline at end of file +UPDATE `tlanguage` SET `name` = 'Deutsch' WHERE `id_language` = 'de'; + +-- ---------------------------------------------------------------------- +-- Table `tncm_vendor` +-- ---------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tncm_vendor` ( + `id` serial, + `name` varchar(255) UNIQUE, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tncm_model` +-- ---------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tncm_model` ( + `id` serial, + `id_vendor` bigint(20) unsigned NOT NULL, + `name` varchar(255) UNIQUE, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_vendor`) REFERENCES `tncm_vendor`(`id`) ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tncm_template` +-- ---------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tncm_template` ( + `id` serial, + `name` text, + `vendors` text, + `models` text, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tncm_script` +-- ---------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tncm_script` ( + `id` serial, + `type` int unsigned not null default 0, + `content` text, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tncm_template_scripts` +-- ---------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tncm_template_scripts` ( + `id` serial, + `id_template` bigint(20) unsigned NOT NULL, + `id_script` bigint(20) unsigned NOT NULL, + PRIMARY KEY (`id`), + FOREIGN KEY (`id_template`) REFERENCES `tncm_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_script`) REFERENCES `tncm_script`(`id`) ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tncm_agent` +-- ---------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tncm_agent` ( + `id_agent` int(10) unsigned NOT NULL, + `id_vendor` bigint(20) unsigned, + `id_model` bigint(20) unsigned, + `protocol` int unsigned not null default 0, + `cred_key` varchar(100), + `adv_key` varchar(100), + `port` int(4) unsigned default 22, + `status` int(4) NOT NULL default 5, + `updated_at` bigint(20) NOT NULL default 0, + `config_backup_id` bigint(20) UNSIGNED DEFAULT NULL, + `id_template` bigint(20) unsigned, + `execute_type` int(2) UNSIGNED NOT NULL default 0, + `execute` int(2) UNSIGNED NOT NULL default 0, + `last_error` text, + PRIMARY KEY (`id_agent`), + FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`cred_key`) REFERENCES `tcredential_store`(`identifier`) ON UPDATE CASCADE ON DELETE SET NULL, + FOREIGN KEY (`id_template`) REFERENCES `tncm_template`(`id`) ON UPDATE CASCADE ON DELETE CASCADE, + FOREIGN KEY (`id_vendor`) REFERENCES `tncm_vendor`(`id`) ON UPDATE CASCADE ON DELETE SET NULL, + FOREIGN KEY (`id_model`) REFERENCES `tncm_model`(`id`) ON UPDATE CASCADE ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------------------------------------------------- +-- Table `tncm_agent_data` +-- ---------------------------------------------------------------------- +CREATE TABLE IF NOT EXISTS `tncm_agent_data` ( + `id` serial, + `id_agent` int(10) unsigned NOT NULL, + `script_type` int unsigned not null, + `data` LONGBLOB, + `status` int(4) NOT NULL default 5, + `updated_at` bigint(20) NOT NULL default 0, + FOREIGN KEY (`id_agent`) REFERENCES `tagente`(`id_agente`) ON UPDATE CASCADE ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +INSERT INTO `tncm_vendor` VALUES + (1,'Cisco'), + (2, 'D-Link Systems, Inc.'), + (3, 'MikroTik'), + (4, 'Alcatel-Lucent Enterprise'), + (5, 'Ubiquiti Networks, Inc.'), + (6, 'Allied Telesis, Inc.'), + (7, 'Frogfoot Networks'), + (8, 'IBM'), + (9, 'Dell Inc.'), + (10, 'Hitachi Communication Technologies, Ltd.'), + (11, 'Netlink'), + (12, 'Ascom'), + (13, 'Synology Inc.'), + (14, 'Fujitsu Network Communications, Inc.'); + +INSERT INTO `tncm_model` VALUES (1,1,'7200'); + +INSERT INTO `tncm_template` VALUES (1,'cisco-base','[\"1\"]','[\"1\"]'); + +INSERT INTO `tncm_script` VALUES + (1,0,'enable expect:Password:\s* _enablepass_ exit'), + (2,1,'enable expect:Password:\s* _enablepass_ term length 0 capture:show running-config exit '), + (3,2,'enable expect:Password:\s* _enablepass_ term length 0 config terminal _applyconfigbackup_ exit '), + (4,3,'enable expect:Password:\s* _enablepass_ term length 0 capture:show version | i IOS Software exit '), + (5,5,'enable expect:Password:\s* _enablepass_ term length 0 config term end end exit '); + +INSERT INTO `tncm_template_scripts`(`id_template`, `id_script`) VALUES (1,1),(1,2),(1,3),(1,4),(1,5); diff --git a/pandora_console/general/first_task/cluster_builder.php b/pandora_console/general/first_task/cluster_builder.php index 157bdce0d7..22c624c9a6 100644 --- a/pandora_console/general/first_task/cluster_builder.php +++ b/pandora_console/general/first_task/cluster_builder.php @@ -46,11 +46,11 @@ ui_require_css_file('first_task'); ui_print_info_message(['no_close' => true, 'message' => __('There are no clusters defined yet.') ]); ?> -
'.html_print_image( 'images/group.png', @@ -616,6 +623,7 @@ if ($id_agente) { 'main' => $maintab, 'remote_configuration' => $remote_configuration_tab, 'module' => $moduletab, + 'ncm' => $ncm_tab, 'alert' => $alerttab, 'template' => $templatetab, 'inventory' => $inventorytab, @@ -631,6 +639,7 @@ if ($id_agente) { 'separator' => '', 'main' => $maintab, 'module' => $moduletab, + 'ncm' => $ncm_tab, 'alert' => $alerttab, 'template' => $templatetab, 'inventory' => $inventorytab, @@ -699,6 +708,11 @@ if ($id_agente) { $tab_name = 'Collection'; break; + case 'ncm': + $tab_description = '- '.__('Network config manager'); + $tab_name = 'Network config manager'; + break; + case 'inventory': $tab_description = '- '.__('Inventory'); $help_header = 'inventory_tab'; @@ -2313,6 +2327,10 @@ switch ($tab) { include 'agent_incidents.php'; break; + case 'ncm': + enterprise_hook('ncm_agent_tab', [$id_agente]); + break; + case 'remote_configuration': enterprise_include('godmode/agentes/agent_disk_conf_editor.php'); break; diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index 1fd203ed3b..6091eabdb2 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -175,6 +175,10 @@ if (check_acl($config['id_user'], 0, 'AW')) { enterprise_hook('agents_submenu'); } +if (check_acl($config['id_user'], 0, 'NW')) { + enterprise_hook('agents_ncm_submenu'); +} + if (check_acl($config['id_user'], 0, 'AW')) { $sub['gmassive']['text'] = __('Bulk operations'); $sub['gmassive']['id'] = 'Bulk operations'; diff --git a/pandora_console/godmode/users/configure_profile.php b/pandora_console/godmode/users/configure_profile.php index 44ef0e6a1e..a6bf49dcb1 100644 --- a/pandora_console/godmode/users/configure_profile.php +++ b/pandora_console/godmode/users/configure_profile.php @@ -123,6 +123,11 @@ if ($id_profile || $new_profile) { $vconsole_edit = 0; $vconsole_management = 0; + // NCM. + $network_config_view = 0; + $network_config_edit = 0; + $network_config_management = 0; + $page_title = __('Create profile'); } else { $profile = db_get_row('tperfil', 'id_perfil', $id_profile); @@ -181,13 +186,41 @@ if ($id_profile || $new_profile) { $vconsole_edit = (bool) $profile['vconsole_edit']; $vconsole_management = (bool) $profile['vconsole_management']; + // NCM. + $network_config_management = (bool) $profile['network_config_management']; + $network_config_view = (bool) $profile['network_config_view'] || $network_config_management; + $network_config_edit = (bool) $profile['network_config_edit'] || $network_config_management; + $id_audit = db_pandora_audit( 'User management', 'Edit profile '.io_safe_output($name) ); enterprise_include_once('include/functions_audit.php'); - $info = 'Name: '.$name.' Agent view: '.$agent_view.' Agent edit: '.$agent_edit.' Agent disable: '.$agent_disable.' Alert edit: '.$alert_edit.' Alert management: '.$alert_management.' User management: '.$user_management.' DB management: '.$db_management.' Event view: '.$event_view.' Event edit: '.$event_edit.' Event management: '.$event_management.' Report view: '.$report_view.' Report edit: '.$report_edit.' Report management: '.$report_management.' Network map view: '.$map_view.' Network map edit: '.$map_edit.' Network map management: '.$map_management.' Visual console view: '.$vconsole_view.' Visual console edit: '.$vconsole_edit.' Visual console management: '.$vconsole_management.' '.get_product_name().' Management: '.$pandora_management; + $info = 'Name: '.$name; + $info .= ' Agent view: '.$agent_view; + $info .= ' Agent edit: '.$agent_edit; + $info .= ' Agent disable: '.$agent_disable; + $info .= ' Alert edit: '.$alert_edit; + $info .= ' Alert management: '.$alert_management; + $info .= ' User management: '.$user_management; + $info .= ' DB management: '.$db_management; + $info .= ' Event view: '.$event_view; + $info .= ' Event edit: '.$event_edit; + $info .= ' Event management: '.$event_management; + $info .= ' Report view: '.$report_view; + $info .= ' Report edit: '.$report_edit; + $info .= ' Report management: '.$report_management; + $info .= ' Network map view: '.$map_view; + $info .= ' Network map edit: '.$map_edit; + $info .= ' Network map management: '.$map_management; + $info .= ' Visual console view: '.$vconsole_view; + $info .= ' Visual console edit: '.$vconsole_edit; + $info .= ' Visual console management: '.$vconsole_management; + $info .= ' Network config view: '.$network_config_view; + $info .= ' Network config write: '.$network_config_write; + $info .= ' Network config management: '.$network_config_management; + $info .= ' '.get_product_name().' Management: '.$pandora_management; enterprise_hook('audit_pandora_enterprise', [$id_audit, $info]); @@ -314,6 +347,21 @@ if ($id_profile || $new_profile) { $disable_option = ''; } + // NCM + $row = []; + $row['name'] = __('View NCM data'); + $row['input'] = html_print_checkbox('network_config_view', 1, $network_config_view, true); + $table->data['VR'] = $row; + $row = []; + $row['name'] = __('Operate NCM'); + $row['input'] = html_print_checkbox('network_config_edit', 1, $network_config_edit, true, false, 'autoclick_profile_users(\'network_config_edit\', \'network_config_view\', \'false\')'); + $table->data['VW'] = $row; + $row = []; + $row['name'] = __('Manage NCM'); + $row['input'] = html_print_checkbox('network_config_management', 1, $network_config_management, true, false, 'autoclick_profile_users(\'network_config_management\', \'network_config_view\', \'network_config_edit\')'); + $table->data['VM'] = $row; + $table->data[] = '