BpNode, process/show: error for missing children...

...and unknown as state

fixes #105
This commit is contained in:
Thomas Gelf 2017-02-20 14:41:15 +01:00
parent 2f3e5fb419
commit 9750e13234
3 changed files with 32 additions and 0 deletions

View file

@ -96,8 +96,13 @@ class ProcessController extends Controller
}
$this->prepareControls($bp, $renderer);
$missing = $bp->getMissingChildren();
if (! empty($missing)) {
$bp->addError(sprintf('There are missing nodes: %s', implode(', ', $missing)));
}
$this->content()->addContent($this->showHints($bp));
$this->content()->addContent($this->showWarnings($bp));
$this->content()->addContent($this->showErrors($bp));
$this->content()->add($renderer);
$this->loadActionForm($bp, $node);
$this->setDynamicAutorefresh();
@ -264,6 +269,20 @@ class ProcessController extends Controller
}
}
protected function showErrors(BpConfig $bp)
{
if ($bp->hasWarnings()) {
$ul = Element::create('ul', array('class' => 'error'));
foreach ($bp->getErrors() as $msg) {
$ul->createElement('li')->addContent($msg);
}
return $ul;
} else {
return null;
}
}
protected function showHints(BpConfig $bp)
{
$ul = Element::create('ul', array('class' => 'error'));

View file

@ -464,6 +464,16 @@ class BpConfig
return $this->createBp($name)->setMissing();
}
public function getMissingChildren()
{
$missing = array();
foreach ($this->getRootNodes() as $root) {
$missing += $root->getMissingChildren();
}
return $missing;
}
public function createImportedNode($config, $name = null)
{
$params = (object) array('configName' => $config);

View file

@ -336,6 +336,9 @@ class BpNode extends Node
$sort_states[] = $child->getSortingState();
$lastStateChange = max($lastStateChange, $child->getLastStateChange());
$bp->endLoopDetection($this->name);
if ($child instanceof MonitoredNode && $child->isMissing()) {
$child->setState(self::ICINGA_UNKNOWN);
}
}
$this->setLastStateChange($lastStateChange);