Commit 4263a476 authored by Kevin Duret's avatar Kevin Duret
Browse files

fix(upgrade): move engine logger upgrade to beta 2 (#11101)

Refs: MON-13287
parent fc9b0359
......@@ -115,28 +115,6 @@ try {
);
}
// Centengine logger v2
if (
$pearDB->isColumnExist('cfg_nagios', 'log_archive_path') === 1
&& $pearDB->isColumnExist('cfg_nagios', 'log_rotation_method') === 1
&& $pearDB->isColumnExist('cfg_nagios', 'daemon_dumps_core') === 1
) {
$errorMessage = "Unable to remove log_archive_path,log_rotation_method,daemon_dumps_core from cfg_nagios table";
$pearDB->query(
"ALTER TABLE `cfg_nagios`
DROP COLUMN `log_archive_path`,
DROP COLUMN `log_rotation_method`,
DROP COLUMN `daemon_dumps_core`"
);
}
if ($pearDB->isColumnExist('cfg_nagios', 'logger_version') !== 1) {
$errorMessage = "Unable to add logger_version to cfg_nagios table";
$pearDB->query(
"ALTER TABLE `cfg_nagios`
ADD COLUMN `logger_version` enum('log_v2_enabled', 'log_legacy_enabled') DEFAULT 'log_v2_enabled'"
);
}
/**
* Transactional queries
*/
......@@ -194,11 +172,6 @@ try {
$errorMessage = 'Unable to exclude Gorgone / MBI / MAP users from password policy';
excludeUsersFromPasswordPolicy($pearDB);
$errorMessage = "Unable to update logger_version from cfg_nagios table";
$pearDB->query(
"UPDATE `cfg_nagios` set logger_version = 'log_legacy_enabled'"
);
$pearDB->commit();
if ($pearDB->isColumnExist('contact', 'contact_passwd') === 1) {
$errorMessage = "Unable to drop column 'contact_passwd' from 'contact' table";
......
......@@ -18,3 +18,50 @@
* For more information : contact@centreon.com
*
*/
require_once __DIR__ . '/../../class/centreonLog.class.php';
$centreonLog = new CentreonLog();
//error specific content
$versionOfTheUpgrade = 'UPGRADE - 22.04.0-beta.2: ';
$errorMessage = '';
try {
// Centengine logger v2
if (
$pearDB->isColumnExist('cfg_nagios', 'log_archive_path') === 1
&& $pearDB->isColumnExist('cfg_nagios', 'log_rotation_method') === 1
&& $pearDB->isColumnExist('cfg_nagios', 'daemon_dumps_core') === 1
) {
$errorMessage = "Unable to remove log_archive_path,log_rotation_method,daemon_dumps_core from cfg_nagios table";
$pearDB->query(
"ALTER TABLE `cfg_nagios`
DROP COLUMN `log_archive_path`,
DROP COLUMN `log_rotation_method`,
DROP COLUMN `daemon_dumps_core`"
);
}
if ($pearDB->isColumnExist('cfg_nagios', 'logger_version') !== 1) {
$errorMessage = "Unable to add logger_version to cfg_nagios table";
$pearDB->query(
"ALTER TABLE `cfg_nagios`
ADD COLUMN `logger_version` enum('log_v2_enabled', 'log_legacy_enabled') DEFAULT 'log_v2_enabled'"
);
}
$errorMessage = "Unable to update logger_version from cfg_nagios table";
$pearDB->query(
"UPDATE `cfg_nagios` set logger_version = 'log_legacy_enabled'"
);
} catch (\Exception $e) {
$centreonLog->insertLog(
4,
$versionOfTheUpgrade . $errorMessage .
" - Code : " . (int)$e->getCode() .
" - Error : " . $e->getMessage() .
" - Trace : " . $e->getTraceAsString()
);
throw new \Exception($versionOfTheUpgrade . $errorMessage, (int) $e->getCode(), $e);
}
INSERT INTO `topology` (`topology_name`, `topology_url`, `readonly`, `is_react`, `topology_parent`, `topology_page`, `topology_group`, `topology_order`) VALUES ('Authentication', '/administration/authentication', '1', '1', 5, 509, 1, 10);
CREATE TABLE IF NOT EXISTS `cfg_nagios_logger` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`cfg_nagios_id` int(11) NOT NULL,
`log_v2_logger` enum('file', 'syslog') DEFAULT 'file',
`log_level_functions` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'err',
`log_level_config` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'info',
`log_level_events` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'info',
`log_level_checks` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'info',
`log_level_notifications` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'err',
`log_level_eventbroker` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'err',
`log_level_external_command` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'info',
`log_level_commands` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'err',
`log_level_downtimes` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'err',
`log_level_comments` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'err',
`log_level_macros` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'err',
`log_level_process` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'info',
`log_level_runtime` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'err',
PRIMARY KEY (`id`),
CONSTRAINT `cfg_nagios_logger_cfg_nagios_id_fk`
FOREIGN KEY (`cfg_nagios_id`)
REFERENCES `cfg_nagios` (`nagios_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
\ No newline at end of file
CREATE TABLE IF NOT EXISTS `cfg_nagios_logger` (
`id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
`cfg_nagios_id` int(11) NOT NULL,
`log_v2_logger` enum('file', 'syslog') DEFAULT 'file',
`log_level_functions` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'err',
`log_level_config` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'info',
`log_level_events` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'info',
`log_level_checks` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'info',
`log_level_notifications` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'err',
`log_level_eventbroker` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'err',
`log_level_external_command` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'info',
`log_level_commands` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'err',
`log_level_downtimes` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'err',
`log_level_comments` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'err',
`log_level_macros` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'err',
`log_level_process` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'info',
`log_level_runtime` enum('trace', 'debug', 'info', 'warning', 'err', 'critical', 'off') DEFAULT 'err',
PRIMARY KEY (`id`),
CONSTRAINT `cfg_nagios_logger_cfg_nagios_id_fk`
FOREIGN KEY (`cfg_nagios_id`)
REFERENCES `cfg_nagios` (`nagios_id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment