Deactivated nodes if not unified

This commit is contained in:
fbsanchez 2021-07-19 13:47:43 +02:00
parent 9183110028
commit 0cec3afba0
7 changed files with 134 additions and 23 deletions

View File

@ -1,5 +1,6 @@
START TRANSACTION;
ALTER TABLE `tmetaconsole_setup` ADD COLUMN `unified` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0;
ALTER TABLE `tlayout` ADD COLUMN `auto_adjust` INTEGER UNSIGNED NOT NULL default 0;
ALTER TABLE `tlayout_data` ADD COLUMN `title` TEXT default '';

View File

@ -418,6 +418,8 @@ ALTER TABLE `tmetaconsole_setup` MODIFY COLUMN `meta_dbuser` text NULL,
ALTER TABLE `tmetaconsole_setup` ADD COLUMN `server_uid` TEXT NOT NULL default '';
ALTER TABLE `tmetaconsole_setup` ADD COLUMN `unified` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0;
-- ---------------------------------------------------------------------
-- Table `tprofile_view`
-- ---------------------------------------------------------------------

View File

@ -0,0 +1,79 @@
<?php
/**
* Static page to lock access to console
*
* @category Wizard
* @package Pandora FMS
* @subpackage Applications.VMware
* @version 1.0.0
* @license See below
*
* ______ ___ _______ _______ ________
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
*
* ============================================================================
* Copyright (c) 2005-2021 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.
* ============================================================================
*/
// Begin.
ui_require_css_file('maintenance');
?>
<html>
<body>
<div class="responsive center padding-6">
<p><?php echo __('You cannot use this node until system is unified'); ?></p>
<br>
<br>
<?php
html_print_image(
'images/maintenance.png',
false,
[
'class' => 'responsive',
'width' => 800,
]
);
?>
<br>
<br>
<p>
<?php
echo __(
'Please navigate to %s to unify system',
'<a href="'.ui_get_meta_url(
'index.php?sec=advanced&sec2=advanced/command_center'
).'" target="_new">'.__('command center').'</a>'
);
?>
</p>
<br>
<p><?php echo __('You will be automatically redirected when all tasks finish'); ?></p>
</div>
</body>
<script type="text/javascript">
$(document).ready(function() {
setTimeout(
function() {
location.reload();
},
10000
);
})
</script>
</html>

View File

@ -1752,11 +1752,27 @@ function has_metaconsole()
* @return boolean
*/
function is_management_allowed($hkey='')
{
return ( (is_metaconsole() && is_centrallised())
|| (!is_metaconsole() && !is_centrallised())
|| (!is_metaconsole() && is_centrallised()) && $hkey == generate_hash_to_api());
}
/**
* Return true if is a centrallised environment.
*
* @return boolean
*/
function is_centrallised()
{
global $config;
return ( (is_metaconsole() && $config['centralized_management'])
|| (!is_metaconsole() && !$config['centralized_management'])
|| (!is_metaconsole() && $config['centralized_management']) && $hkey == generate_hash_to_api());
if (isset($config['centralized_management']) === false) {
return false;
}
return (bool) $config['centralized_management'];
}
@ -1768,8 +1784,7 @@ function is_management_allowed($hkey='')
*/
function is_central_policies()
{
global $config;
return is_metaconsole() && $config['centralized_management'];
return is_metaconsole() && is_centrallised();
}

View File

@ -22,8 +22,12 @@ h1 {
color: #83b92f;
}
p a {
font-size: 1rem;
}
p {
font-size: 2rem;
font-size: 1rem;
margin-bottom: 0.5rem;
letter-spacing: 1.5px;
font-weight: lighter;

View File

@ -1040,6 +1040,30 @@ if (isset($_GET['bye'])) {
clear_pandora_error_for_header();
if ((bool) $config['node_deactivated'] === true) {
// Prevent access node if not merged.
include 'general/node_deactivated.php';
while (ob_get_length() > 0) {
ob_end_flush();
}
exit('</html>');
}
if ((bool) $config['maintenance_mode'] === true
&& (bool) users_is_admin() === false
) {
// Show maintenance web-page. For non-admin users only.
include 'general/maintenance.php';
while (ob_get_length() > 0) {
ob_end_flush();
}
exit('</html>');
}
/*
* ----------------------------------------------------------------------
* EXTENSIONS
@ -1087,21 +1111,6 @@ if (get_parameter('login', 0) !== 0) {
}
}
if ((bool) $config['maintenance_mode'] === true
&& (bool) users_is_admin() === false
) {
// Show maintenance web-page. For non-admin users only.
include 'general/maintenance.php';
while (ob_get_length() > 0) {
ob_end_flush();
}
exit('</html>');
}
// Header.
if ($config['pure'] == 0) {
echo '<div id="container"><div id="head">';

View File

@ -2747,8 +2747,9 @@ CREATE TABLE IF NOT EXISTS `tmetaconsole_setup` (
`auth_token` text,
`id_group` int(10) unsigned NOT NULL default 0,
`api_password` text NOT NULL,
`disabled` tinyint(1) unsigned NOT NULL default '0',
`last_event_replication` bigint(20) default '0',
`disabled` tinyint(1) unsigned NOT NULL default 0,
`unified` tinyint(1) unsigned NOT NULL default 0,
`last_event_replication` bigint(20) default 0,
`server_uid` text NOT NULL default '',
PRIMARY KEY (`id`)
) ENGINE=InnoDB