mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-23 05:44:37 +02:00
IcingaConfig(Legacy): Add deployment mode for Icinga 1 config
refs #13049
This commit is contained in:
parent
4f2dbdf5e8
commit
003a100b9c
@ -84,7 +84,6 @@ class SettingsForm extends QuickForm
|
|||||||
array(
|
array(
|
||||||
'v2' => $this->translate('Icinga v2.x'),
|
'v2' => $this->translate('Icinga v2.x'),
|
||||||
'v1' => $this->translate('Icinga v1.x'),
|
'v1' => $this->translate('Icinga v1.x'),
|
||||||
// Hiding for now 'v1-masterless' => $this->translate('Icinga v1.x (no master)'),
|
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'description' => $this->translate(
|
'description' => $this->translate(
|
||||||
@ -96,6 +95,24 @@ class SettingsForm extends QuickForm
|
|||||||
'value' => $settings->getStoredValue('config_format')
|
'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'));
|
$this->setSubmitLabel($this->translate('Store'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,8 @@ class IcingaConfig
|
|||||||
|
|
||||||
protected $configFormat;
|
protected $configFormat;
|
||||||
|
|
||||||
|
protected $deploymentModeV1;
|
||||||
|
|
||||||
public static $table = 'director_generated_config';
|
public static $table = 'director_generated_config';
|
||||||
|
|
||||||
public function __construct(Db $connection)
|
public function __construct(Db $connection)
|
||||||
@ -48,6 +50,7 @@ class IcingaConfig
|
|||||||
$this->connection = $connection;
|
$this->connection = $connection;
|
||||||
$this->db = $connection->getDbAdapter();
|
$this->db = $connection->getDbAdapter();
|
||||||
$this->configFormat = $this->connection->settings()->config_format;
|
$this->configFormat = $this->connection->settings()->config_format;
|
||||||
|
$this->deploymentModeV1 = $this->connection->settings()->deployment_mode_v1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSize()
|
public function getSize()
|
||||||
@ -74,6 +77,16 @@ class IcingaConfig
|
|||||||
return $this->configFormat;
|
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)
|
public function setConfigFormat($format)
|
||||||
{
|
{
|
||||||
if (! in_array($format, array('v1', 'v2'))) {
|
if (! in_array($format, array('v1', 'v2'))) {
|
||||||
@ -90,7 +103,7 @@ class IcingaConfig
|
|||||||
|
|
||||||
public function isLegacy()
|
public function isLegacy()
|
||||||
{
|
{
|
||||||
return strpos($this->configFormat, 'v1') === 0;
|
return $this->configFormat === 'v1';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getObjectCount()
|
public function getObjectCount()
|
||||||
|
@ -1479,18 +1479,26 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer
|
|||||||
|
|
||||||
$filename = $this->getRenderingFilename();
|
$filename = $this->getRenderingFilename();
|
||||||
|
|
||||||
if (
|
$deploymentMode = $config->getDeploymentMode();
|
||||||
$this->getResolvedProperty('zone_id')
|
if ($deploymentMode === 'active-passive') {
|
||||||
&& array_key_exists('enable_active_checks', $this->defaultProperties)
|
if (
|
||||||
&& $config->getConfigFormat() !== 'v1-masterless'
|
$this->getResolvedProperty('zone_id')
|
||||||
) {
|
&& array_key_exists('enable_active_checks', $this->defaultProperties)
|
||||||
$passive = clone($this);
|
) {
|
||||||
$passive->enable_active_checks = false;
|
$passive = clone($this);
|
||||||
|
$passive->enable_active_checks = false;
|
||||||
|
|
||||||
$config->configFile(
|
$config->configFile(
|
||||||
'director/master/' . $filename,
|
'director/master/' . $filename,
|
||||||
'.cfg'
|
'.cfg'
|
||||||
)->addLegacyObject($passive);
|
)->addLegacyObject($passive);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif ($deploymentMode === 'masterless') {
|
||||||
|
// no additional config
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new ProgrammingError('Unsupported deployment mode: %s' .$deploymentMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
$config->configFile(
|
$config->configFile(
|
||||||
|
@ -18,6 +18,7 @@ class Settings
|
|||||||
'override_services_templatename' => 'host var overrides (Director)',
|
'override_services_templatename' => 'host var overrides (Director)',
|
||||||
'disable_all_jobs' => 'n', // 'y'
|
'disable_all_jobs' => 'n', // 'y'
|
||||||
'enable_audit_log' => 'n',
|
'enable_audit_log' => 'n',
|
||||||
|
'deployment_mode_v1' => 'active-passive',
|
||||||
// 'experimental_features' => null, // 'allow'
|
// 'experimental_features' => null, // 'allow'
|
||||||
// 'master_zone' => null,
|
// 'master_zone' => null,
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user