diff --git a/application/forms/SettingsForm.php b/application/forms/SettingsForm.php index 4a0e81ab..28813561 100644 --- a/application/forms/SettingsForm.php +++ b/application/forms/SettingsForm.php @@ -84,7 +84,6 @@ class SettingsForm extends QuickForm array( 'v2' => $this->translate('Icinga v2.x'), 'v1' => $this->translate('Icinga v1.x'), - // Hiding for now 'v1-masterless' => $this->translate('Icinga v1.x (no master)'), ) ), 'description' => $this->translate( @@ -96,6 +95,24 @@ class SettingsForm extends QuickForm 'value' => $settings->getStoredValue('config_format') )); + if ($settings->getStoredValue('config_format') === 'v1') { + $this->addElement('select', 'deployment_mode_v1', array( + 'label' => $this->translate('Deployment mode'), + 'multiOptions' => $this->eventuallyConfiguredEnum( + 'deployment_mode_v1', + array( + 'active-passive' => $this->translate('Active-Passive'), + 'masterless' => $this->translate('Master-less'), + ) + ), + 'description' => $this->translate( + 'Deployment mode for Icinga 1 configuration' + ), + 'value' => $settings->getStoredValue('deployment_mode_v1') + )); + + } + $this->setSubmitLabel($this->translate('Store')); } diff --git a/library/Director/IcingaConfig/IcingaConfig.php b/library/Director/IcingaConfig/IcingaConfig.php index b14c5a7c..5f61c3a8 100644 --- a/library/Director/IcingaConfig/IcingaConfig.php +++ b/library/Director/IcingaConfig/IcingaConfig.php @@ -38,6 +38,8 @@ class IcingaConfig protected $configFormat; + protected $deploymentModeV1; + public static $table = 'director_generated_config'; public function __construct(Db $connection) @@ -48,6 +50,7 @@ class IcingaConfig $this->connection = $connection; $this->db = $connection->getDbAdapter(); $this->configFormat = $this->connection->settings()->config_format; + $this->deploymentModeV1 = $this->connection->settings()->deployment_mode_v1; } public function getSize() @@ -74,6 +77,16 @@ class IcingaConfig return $this->configFormat; } + public function getDeploymentMode() + { + if ($this->isLegacy()) { + return $this->deploymentModeV1; + } + else { + throw new ProgrammingError('There is no deployment mode for Icinga 2 config format!'); + } + } + public function setConfigFormat($format) { if (! in_array($format, array('v1', 'v2'))) { @@ -90,7 +103,7 @@ class IcingaConfig public function isLegacy() { - return strpos($this->configFormat, 'v1') === 0; + return $this->configFormat === 'v1'; } public function getObjectCount() diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php index 280fb778..5961d77c 100644 --- a/library/Director/Objects/IcingaObject.php +++ b/library/Director/Objects/IcingaObject.php @@ -1479,18 +1479,26 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer $filename = $this->getRenderingFilename(); - if ( - $this->getResolvedProperty('zone_id') - && array_key_exists('enable_active_checks', $this->defaultProperties) - && $config->getConfigFormat() !== 'v1-masterless' - ) { - $passive = clone($this); - $passive->enable_active_checks = false; + $deploymentMode = $config->getDeploymentMode(); + if ($deploymentMode === 'active-passive') { + if ( + $this->getResolvedProperty('zone_id') + && array_key_exists('enable_active_checks', $this->defaultProperties) + ) { + $passive = clone($this); + $passive->enable_active_checks = false; - $config->configFile( - 'director/master/' . $filename, - '.cfg' - )->addLegacyObject($passive); + $config->configFile( + 'director/master/' . $filename, + '.cfg' + )->addLegacyObject($passive); + } + } + elseif ($deploymentMode === 'masterless') { + // no additional config + } + else { + throw new ProgrammingError('Unsupported deployment mode: %s' .$deploymentMode); } $config->configFile( diff --git a/library/Director/Settings.php b/library/Director/Settings.php index 5fe19d54..f2e2d1c5 100644 --- a/library/Director/Settings.php +++ b/library/Director/Settings.php @@ -18,6 +18,7 @@ class Settings 'override_services_templatename' => 'host var overrides (Director)', 'disable_all_jobs' => 'n', // 'y' 'enable_audit_log' => 'n', + 'deployment_mode_v1' => 'active-passive', // 'experimental_features' => null, // 'allow' // 'master_zone' => null, );