Enable propagate host downtime commands for Icinga 2

This only works when using the latest Icinga 2 snapshot packages. Before releasing Web 2.4.0, we have to include a check to only offer these commands when using Icinga 2 2.6.0+

refs #10774
This commit is contained in:
Eric Lippmann 2016-11-08 15:27:29 +01:00
parent 2b060d9bd4
commit 93474972bf
2 changed files with 23 additions and 18 deletions

View File

@ -34,24 +34,22 @@ class ScheduleHostDowntimeCommandForm extends ScheduleServiceDowntimeCommandForm
) )
); );
if (! $this->getBackend()->isIcinga2()) { $this->addElement(
$this->addElement( 'select',
'select', 'child_hosts',
'child_hosts', array(
array( 'description' => $this->translate(
'description' => $this->translate( 'Define what should be done with the child hosts of the hosts.'
'Define what should be done with the child hosts of the hosts.' ),
), 'label' => $this->translate('Child Hosts'),
'label' => $this->translate('Child Hosts'), 'multiOptions' => array(
'multiOptions' => array( 0 => $this->translate('Do nothing with child hosts'),
0 => $this->translate('Do nothing with child hosts'), 1 => $this->translate('Schedule triggered downtime for all child hosts'),
1 => $this->translate('Schedule triggered downtime for all child hosts'), 2 => $this->translate('Schedule non-triggered downtime for all child hosts')
2 => $this->translate('Schedule non-triggered downtime for all child hosts') ),
), 'value' => 0
'value' => 0 )
) );
);
}
return $this; return $this;
} }

View File

@ -10,6 +10,7 @@ use Icinga\Module\Monitoring\Command\Object\AddCommentCommand;
use Icinga\Module\Monitoring\Command\Object\DeleteCommentCommand; use Icinga\Module\Monitoring\Command\Object\DeleteCommentCommand;
use Icinga\Module\Monitoring\Command\Object\DeleteDowntimeCommand; use Icinga\Module\Monitoring\Command\Object\DeleteDowntimeCommand;
use Icinga\Module\Monitoring\Command\Object\ProcessCheckResultCommand; use Icinga\Module\Monitoring\Command\Object\ProcessCheckResultCommand;
use Icinga\Module\Monitoring\Command\Object\PropagateHostDowntimeCommand;
use Icinga\Module\Monitoring\Command\Object\RemoveAcknowledgementCommand; use Icinga\Module\Monitoring\Command\Object\RemoveAcknowledgementCommand;
use Icinga\Module\Monitoring\Command\Object\ScheduleServiceCheckCommand; use Icinga\Module\Monitoring\Command\Object\ScheduleServiceCheckCommand;
use Icinga\Module\Monitoring\Command\Object\ScheduleServiceDowntimeCommand; use Icinga\Module\Monitoring\Command\Object\ScheduleServiceDowntimeCommand;
@ -148,6 +149,12 @@ class IcingaApiCommandRenderer implements IcingaCommandRendererInterface
'fixed' => $command->getFixed(), 'fixed' => $command->getFixed(),
'trigger_name' => $command->getTriggerId() 'trigger_name' => $command->getTriggerId()
); );
if ($command->getObject()->getType() === $command::TYPE_HOST
&& $command instanceof PropagateHostDowntimeCommand
) {
/** @var \Icinga\Module\Monitoring\Command\Object\PropagateHostDowntimeCommand $command */
$data['child_options'] = $command->getTriggered() ? 1 : 2;
}
$this->applyFilter($data, $command->getObject()); $this->applyFilter($data, $command->getObject());
return IcingaApiCommand::create($endpoint, $data); return IcingaApiCommand::create($endpoint, $data);
} }