Merge branch 'bugfix/disable-comment-persisent-for-icinga2-11100'
fixes #11100
This commit is contained in:
commit
70d296ea32
|
@ -93,6 +93,7 @@ class HealthController extends Controller
|
|||
$this->view->programStatus = $programStatus;
|
||||
$toggleFeaturesForm = new ToggleInstanceFeaturesCommandForm();
|
||||
$toggleFeaturesForm
|
||||
->setBackend($this->backend)
|
||||
->setStatus($programStatus)
|
||||
->load($programStatus)
|
||||
->handleRequest();
|
||||
|
|
|
@ -151,7 +151,6 @@ class HostController extends MonitoredObjectController
|
|||
$this->assertPermission('monitoring/command/downtime/schedule');
|
||||
|
||||
$form = new ScheduleHostDowntimeCommandForm();
|
||||
$form->setBackend($this->backend);
|
||||
$form->setTitle($this->translate('Schedule Host Downtime'));
|
||||
$this->handleCommandForm($form);
|
||||
}
|
||||
|
@ -164,7 +163,6 @@ class HostController extends MonitoredObjectController
|
|||
$this->assertPermission('monitoring/command/process-check-result');
|
||||
|
||||
$form = new ProcessCheckResultCommandForm();
|
||||
$form->setBackend($this->backend);
|
||||
$form->setTitle($this->translate('Submit Passive Host Check Result'));
|
||||
$this->handleCommandForm($form);
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ class HostsController extends Controller
|
|||
protected function handleCommandForm(ObjectsCommandForm $form)
|
||||
{
|
||||
$form
|
||||
->setBackend($this->backend)
|
||||
->setObjects($this->hostList)
|
||||
->setRedirectUrl(Url::fromPath('monitoring/hosts/show')->setParams($this->params))
|
||||
->handleRequest();
|
||||
|
@ -194,7 +195,6 @@ class HostsController extends Controller
|
|||
$this->assertPermission('monitoring/command/downtime/schedule');
|
||||
|
||||
$form = new ScheduleHostDowntimeCommandForm();
|
||||
$form->setBackend($this->backend);
|
||||
$form->setTitle($this->translate('Schedule Host Downtimes'));
|
||||
$this->handleCommandForm($form);
|
||||
}
|
||||
|
@ -207,7 +207,6 @@ class HostsController extends Controller
|
|||
$this->assertPermission('monitoring/command/process-check-result');
|
||||
|
||||
$form = new ProcessCheckResultCommandForm();
|
||||
$form->setBackend($this->backend);
|
||||
$form->setTitle($this->translate('Submit Passive Host Check Results'));
|
||||
$this->handleCommandForm($form);
|
||||
}
|
||||
|
|
|
@ -121,7 +121,6 @@ class ServiceController extends MonitoredObjectController
|
|||
$this->assertPermission('monitoring/command/process-check-result');
|
||||
|
||||
$form = new ProcessCheckResultCommandForm();
|
||||
$form->setBackend($this->backend);
|
||||
$form->setTitle($this->translate('Submit Passive Service Check Result'));
|
||||
$this->handleCommandForm($form);
|
||||
}
|
||||
|
|
|
@ -75,6 +75,7 @@ class ServicesController extends Controller
|
|||
protected function handleCommandForm(ObjectsCommandForm $form)
|
||||
{
|
||||
$form
|
||||
->setBackend($this->backend)
|
||||
->setObjects($this->serviceList)
|
||||
->setRedirectUrl(Url::fromPath('monitoring/services/show')->setParams($this->params))
|
||||
->handleRequest();
|
||||
|
@ -209,7 +210,6 @@ class ServicesController extends Controller
|
|||
$this->assertPermission('monitoring/command/process-check-result');
|
||||
|
||||
$form = new ProcessCheckResultCommandForm();
|
||||
$form->setBackend($this->backend);
|
||||
$form->setTitle($this->translate('Submit Passive Service Check Results'));
|
||||
$this->handleCommandForm($form);
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ class ToggleInstanceFeaturesCommandForm extends CommandForm
|
|||
)
|
||||
);
|
||||
|
||||
if (! preg_match('~^v2\.\d+\.\d+.*$~', $this->status->program_version)) {
|
||||
if (! $this->getBackend()->isIcinga2($this->status->program_version)) {
|
||||
$this->addElement(
|
||||
'checkbox',
|
||||
ToggleInstanceFeatureCommand::FEATURE_HOST_OBSESSING,
|
||||
|
|
|
@ -34,21 +34,21 @@ class AddCommentCommandForm extends ObjectsCommandForm
|
|||
*/
|
||||
public function createElements(array $formData = array())
|
||||
{
|
||||
$this->addElements(array(
|
||||
$this->addElement(
|
||||
'textarea',
|
||||
'comment',
|
||||
array(
|
||||
'textarea',
|
||||
'comment',
|
||||
array(
|
||||
'required' => true,
|
||||
'label' => $this->translate('Comment'),
|
||||
'description' => $this->translate(
|
||||
'If you work with other administrators, you may find it useful to share information about the'
|
||||
. ' the host or service that is having problems. Make sure you enter a brief description of'
|
||||
. ' what you are doing.'
|
||||
)
|
||||
'required' => true,
|
||||
'label' => $this->translate('Comment'),
|
||||
'description' => $this->translate(
|
||||
'If you work with other administrators, you may find it useful to share information about the'
|
||||
. ' the host or service that is having problems. Make sure you enter a brief description of'
|
||||
. ' what you are doing.'
|
||||
)
|
||||
),
|
||||
array(
|
||||
)
|
||||
);
|
||||
if (! $this->getBackend()->isIcinga2()) {
|
||||
$this->addElement(
|
||||
'checkbox',
|
||||
'persistent',
|
||||
array(
|
||||
|
@ -59,8 +59,8 @@ class AddCommentCommandForm extends ObjectsCommandForm
|
|||
. ' restarted.'
|
||||
)
|
||||
)
|
||||
)
|
||||
));
|
||||
);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,9 @@ class AddCommentCommandForm extends ObjectsCommandForm
|
|||
$comment->setObject($object);
|
||||
$comment->setComment($this->getElement('comment')->getValue());
|
||||
$comment->setAuthor($this->request->getUser()->getUsername());
|
||||
$comment->setPersistent($this->getElement('persistent')->isChecked());
|
||||
if (($persistent = $this->getElement('persistent')) !== null) {
|
||||
$comment->setPersistent($persistent->isChecked());
|
||||
}
|
||||
$this->getTransport($this->request)->send($comment);
|
||||
}
|
||||
Notification::success($this->translatePlural(
|
||||
|
|
|
@ -124,7 +124,7 @@ class ProcessCheckResultCommandForm extends ObjectsCommandForm
|
|||
ProcessCheckResultCommand::HOST_DOWN => $this->translate('DOWN', 'icinga.state')
|
||||
);
|
||||
|
||||
if (substr($this->getBackend()->getProgramVersion(), 0, 2) !== 'v2') {
|
||||
if (! $this->getBackend()->isIcinga2()) {
|
||||
$options[ProcessCheckResultCommand::HOST_UNREACHABLE] = $this->translate('UNREACHABLE', 'icinga.state');
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class ScheduleHostDowntimeCommandForm extends ScheduleServiceDowntimeCommandForm
|
|||
)
|
||||
);
|
||||
|
||||
if (substr($this->getBackend()->getProgramVersion(), 0, 2) !== 'v2') {
|
||||
if (! $this->getBackend()->isIcinga2()) {
|
||||
$this->addElement(
|
||||
'select',
|
||||
'child_hosts',
|
||||
|
|
|
@ -59,7 +59,7 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm
|
|||
'permission' => 'monitoring/command/feature/object/flap-detection'
|
||||
)
|
||||
);
|
||||
if (preg_match('~^[vr]2\.\d+\.\d+.*$~', $this->getIcingaVersion())) {
|
||||
if ($this->getBackend()->isIcinga2()) {
|
||||
unset($features[ToggleObjectFeatureCommand::FEATURE_OBSESSING]);
|
||||
}
|
||||
$this->features = $features;
|
||||
|
@ -176,14 +176,4 @@ class ToggleObjectFeaturesCommandForm extends ObjectsCommandForm
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch and return the program version of the current instance
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getIcingaVersion()
|
||||
{
|
||||
return $this->getBackend()->select()->from('programstatus', array('program_version'))->fetchOne();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -341,4 +341,22 @@ class MonitoringBackend implements Selectable, Queryable, ConnectionInterface
|
|||
{
|
||||
return $this->select()->from('programstatus', array('program_version'))->fetchOne();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether the backend is Icinga 2
|
||||
*
|
||||
* @param string $programVersion
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isIcinga2($programVersion = null)
|
||||
{
|
||||
if ($programVersion === null) {
|
||||
$programVersion = $this->select()->from('programstatus', array('program_version'))->fetchOne();
|
||||
}
|
||||
return (bool) preg_match(
|
||||
'/^[vr]2\.\d+\.\d+.*$/',
|
||||
$programVersion
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,6 +122,7 @@ abstract class MonitoredObjectController extends Controller
|
|||
protected function handleCommandForm(ObjectsCommandForm $form)
|
||||
{
|
||||
$form
|
||||
->setBackend($this->backend)
|
||||
->setObjects($this->object)
|
||||
->setRedirectUrl(Url::fromPath($this->commandRedirectUrl)->setParams($this->params))
|
||||
->handleRequest();
|
||||
|
|
Loading…
Reference in New Issue