SyncJob: really run, add check for changes

This commit is contained in:
Thomas Gelf 2016-05-19 15:09:45 +02:00
parent 2007dee6c0
commit cea75ead0e

View File

@ -5,18 +5,30 @@ namespace Icinga\Module\Director\Job;
use Icinga\Module\Director\Db; use Icinga\Module\Director\Db;
use Icinga\Module\Director\Hook\JobHook; use Icinga\Module\Director\Hook\JobHook;
use Icinga\Module\Director\Web\Form\QuickForm; use Icinga\Module\Director\Web\Form\QuickForm;
use Icinga\Module\Director\Objects\SyncRule;
class SyncJob extends JobHook class SyncJob extends JobHook
{ {
protected $rule;
public function run() public function run()
{ {
if ($this->getSetting('apply_changes') === 'y') { if ($this->getSetting('apply_changes') === 'y') {
$this->syncRule()->applyChanges(); $this->syncRule()->applyChanges();
} else{ } else {
$this->syncRule()->checkForChanges(); $this->syncRule()->checkForChanges();
} }
} }
protected function syncRule()
{
if ($this->rule === null) {
$this->rule = SyncRule::load($this->getSetting('rule_id'), $this->db());
}
return $this->rule;
}
public static function getDescription(QuickForm $form) public static function getDescription(QuickForm $form)
{ {
return $form->translate( return $form->translate(