From cd989f9c3aff968e19a3aeabc4eb9085787a6673 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:43:12 +0200 Subject: Adding upstream version 1.10.2. Signed-off-by: Daniel Baumann --- library/Director/Job/ConfigJob.php | 75 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 library/Director/Job/ConfigJob.php (limited to 'library/Director/Job/ConfigJob.php') diff --git a/library/Director/Job/ConfigJob.php b/library/Director/Job/ConfigJob.php new file mode 100644 index 0000000..fda3043 --- /dev/null +++ b/library/Director/Job/ConfigJob.php @@ -0,0 +1,75 @@ +db(); + $deployer = new ConditionalDeployment($db); + $renderer = new ConditionalConfigRenderer($db); + if ($grace = $this->getSetting('grace_period')) { + $deployer->setGracePeriod(new DeploymentGracePeriod((int) $grace, $db)); + } + if ($this->getSetting('force_generate') === 'y') { + $renderer->forceRendering(); + } + + $deployer->deploy($renderer->getConfig()); + } + + public static function addSettingsFormFields(QuickForm $form) + { + $form->addElement('select', 'force_generate', [ + 'label' => $form->translate('Force rendering'), + 'description' => $form->translate( + 'Whether rendering should be forced. If not enforced, this' + . ' job re-renders the configuration only when there have been' + . ' activities since the last rendered config' + ), + 'value' => 'n', + 'multiOptions' => [ + 'y' => $form->translate('Yes'), + 'n' => $form->translate('No'), + ] + ]); + + $form->addElement('select', 'deploy_when_changed', [ + 'label' => $form->translate('Deploy modified config'), + 'description' => $form->translate( + 'This allows you to immediately deploy a modified configuration' + ), + 'value' => 'n', + 'multiOptions' => [ + 'y' => $form->translate('Yes'), + 'n' => $form->translate('No'), + ] + ]); + + $form->addElement('text', 'grace_period', array( + 'label' => $form->translate('Grace period'), + 'description' => $form->translate( + 'When deploying configuration, wait at least this amount of' + . ' seconds unless the next deployment should take place' + ), + 'value' => 600, + )); + + return $form; + } + + public static function getDescription(QuickForm $form) + { + return $form->translate( + 'The Config job allows you to generate and eventually deploy your' + . ' Icinga 2 configuration' + ); + } +} -- cgit v1.2.3