Added a setup section for ehorus
(cherry picked from commit e3cfca24ed
)
This commit is contained in:
parent
40b8efc532
commit
5191f8658a
|
@ -97,6 +97,10 @@ if (check_acl ($config['id_user'], 0, "AW")) {
|
|||
}
|
||||
}
|
||||
|
||||
$buttons['ehorus'] = array('active' => false,
|
||||
'text' => '<a href="index.php?sec=gsetup&sec2=godmode/setup/setup§ion=ehorus">' .
|
||||
html_print_image("images/operation.png", true, array ("title" => __('eHorus'))) . '</a>');
|
||||
|
||||
$help_header = '';
|
||||
if (enterprise_installed()) {
|
||||
$subpage = setup_enterprise_add_subsection_main($section, $buttons, $help_header);
|
||||
|
@ -124,6 +128,10 @@ switch ($section) {
|
|||
$buttons['net']['active'] = true;
|
||||
$subpage = ' » ' . __('Netflow');
|
||||
break;
|
||||
case 'ehorus':
|
||||
$buttons['ehorus']['active'] = true;
|
||||
$subpage = ' » ' . __('eHorus');
|
||||
break;
|
||||
}
|
||||
|
||||
// Header
|
||||
|
@ -156,6 +164,9 @@ switch ($section) {
|
|||
case "vis":
|
||||
require_once($config['homedir'] . "/godmode/setup/setup_visuals.php");
|
||||
break;
|
||||
case "ehorus":
|
||||
require_once($config['homedir'] . "/godmode/setup/setup_ehorus.php");
|
||||
break;
|
||||
default:
|
||||
enterprise_hook('setup_enterprise_select_tab', array($section));
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2010 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 General Public License
|
||||
// as published by the Free Software Foundation for 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.
|
||||
|
||||
// Warning: This file may be required into the metaconsole's setup
|
||||
|
||||
// Load global vars
|
||||
global $config;
|
||||
|
||||
check_login ();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, "PM") && ! is_user_admin($config['id_user'])) {
|
||||
db_pandora_audit("ACL Violation", "Trying to access Setup Management");
|
||||
require ("general/noaccess.php");
|
||||
return;
|
||||
}
|
||||
|
||||
$table = new StdClass();
|
||||
$table->data = array();
|
||||
$table->width = '100%';
|
||||
$table->id = 'ehorus-setup';
|
||||
$table->class = 'databox filters';
|
||||
$table->size['name'] = '30%';
|
||||
$table->style['name'] = "font-weight: bold";
|
||||
|
||||
if (!$config['ehorus_enabled']) {
|
||||
$table->rowstyle = array();
|
||||
$table->rowstyle['ehorus_user'] = 'display: none';
|
||||
$table->rowstyle['ehorus_pass'] = 'display: none';
|
||||
$table->rowstyle['ehorus_hostname'] = 'display: none';
|
||||
$table->rowstyle['ehorus_port'] = 'display: none';
|
||||
$table->rowstyle['ehorus_req_timeout'] = 'display: none';
|
||||
}
|
||||
|
||||
// Enable eHorus
|
||||
$row = array();
|
||||
$row['name'] = __('Enable eHorus');
|
||||
$row['control'] = __('Yes').' '.html_print_radio_button ('ehorus_enabled', 1, '', $config['ehorus_enabled'], true).' ';
|
||||
$row['control'] .= __('No').' '.html_print_radio_button ('ehorus_enabled', 0, '', $config['ehorus_enabled'], true);
|
||||
$table->data['ehorus_enabled'] = $row;
|
||||
|
||||
// User
|
||||
$row = array();
|
||||
$row['name'] = __('User');
|
||||
$row['control'] = html_print_input_text('ehorus_user', $config['ehorus_user'], '', 30, 100, true);
|
||||
$table->data['ehorus_user'] = $row;
|
||||
|
||||
// Pass
|
||||
$row = array();
|
||||
$row['name'] = __('Password');
|
||||
$row['control'] = html_print_input_password('ehorus_pass', io_output_password($config['ehorus_pass']), '', 30, 100, true);
|
||||
$table->data['ehorus_pass'] = $row;
|
||||
|
||||
// Directory hostname
|
||||
$row = array();
|
||||
$row['name'] = __('API Hostname');
|
||||
$row['control'] = html_print_input_text('ehorus_hostname', $config['ehorus_hostname'], '', 30, 100, true);
|
||||
$row['control'] .= ui_print_help_tip(__('Hostname of the eHorus API') . '. ' . __('Without protocol and port') . '. ' . __('e.g., switch.ehorus.com'), true);
|
||||
$table->data['ehorus_hostname'] = $row;
|
||||
|
||||
// Directory port
|
||||
$row = array();
|
||||
$row['name'] = __('API Port');
|
||||
$row['control'] = html_print_input_text('ehorus_port', $config['ehorus_port'], '', 6, 100, true);
|
||||
$row['control'] .= ui_print_help_tip(__('e.g., 18080'), true);
|
||||
$table->data['ehorus_port'] = $row;
|
||||
|
||||
// Request timeout
|
||||
$row = array();
|
||||
$row['name'] = __('Request timeout');
|
||||
$row['control'] = html_print_input_text('ehorus_req_timeout', $config['ehorus_req_timeout'], '', 3, 10, true);
|
||||
$row['control'] .= ui_print_help_tip(__('Time in seconds to set the maximum time of the requests to the eHorus API') . '. ' . __('0 to disable'), true);
|
||||
$table->data['ehorus_req_timeout'] = $row;
|
||||
|
||||
// Form
|
||||
echo '<form id="form_setup" method="post">';
|
||||
html_print_input_hidden('update_config', 1);
|
||||
html_print_table($table);
|
||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||
html_print_submit_button(__('Update'), 'update_button', false, 'class="sub upd"');
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
var showFields = function () {
|
||||
$('table#ehorus-setup tr:not(:first-child)').show();
|
||||
}
|
||||
var hideFields = function () {
|
||||
$('table#ehorus-setup tr:not(:first-child)').hide();
|
||||
}
|
||||
var handleEnable = function (event) {
|
||||
if (event.target.value == '1') showFields();
|
||||
else hideFields();
|
||||
}
|
||||
$('input:radio[name="ehorus_enabled"]').change(handleEnable);
|
||||
</script>
|
|
@ -641,6 +641,20 @@ function config_update_config () {
|
|||
if (!config_update_value ('history_db_delay', get_parameter ('history_db_delay')))
|
||||
$error_update[] = __('Delay');
|
||||
break;
|
||||
case 'ehorus':
|
||||
if (!config_update_value('ehorus_enabled', (int) get_parameter('ehorus_enabled')))
|
||||
$error_update[] = __('Enable eHorus');
|
||||
if (!config_update_value('ehorus_user', get_parameter('ehorus_user')))
|
||||
$error_update[] = __('eHorus user');
|
||||
if (!config_update_value('ehorus_pass', io_input_password(get_parameter('ehorus_pass'))))
|
||||
$error_update[] = __('eHorus password');
|
||||
if (!config_update_value('ehorus_hostname', get_parameter('ehorus_hostname')))
|
||||
$error_update[] = __('eHorus API hostname');
|
||||
if (!config_update_value('ehorus_port', (int) get_parameter('ehorus_port')))
|
||||
$error_update[] = __('eHorus API port');
|
||||
if (!config_update_value('ehorus_req_timeout', (int) get_parameter('ehorus_req_timeout')))
|
||||
$error_update[] = __('eHorus request timeout');
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
@ -1460,7 +1474,19 @@ function config_process_config () {
|
|||
config_update_value ('instance_registered', 0);
|
||||
}
|
||||
|
||||
|
||||
// eHorus
|
||||
if (!isset($config['ehorus_enabled'])) {
|
||||
config_update_value('ehorus_enabled', 0);
|
||||
}
|
||||
if (!isset($config['ehorus_hostname'])) {
|
||||
config_update_value('ehorus_hostname', 'switch.ehorus.com');
|
||||
}
|
||||
if (!isset($config['ehorus_port'])) {
|
||||
config_update_value('ehorus_port', 18080);
|
||||
}
|
||||
if (!isset($config['ehorus_req_timeout'])) {
|
||||
config_update_value('ehorus_req_timeout', 5);
|
||||
}
|
||||
|
||||
/* Finally, check if any value was overwritten in a form */
|
||||
config_update_config();
|
||||
|
|
Loading…
Reference in New Issue