Make changes to support the case when icingadb is set as the preferred backend.

This commit is contained in:
raviks789 2021-11-17 17:28:05 +01:00
parent 685f44d118
commit 69e879a745
7 changed files with 22 additions and 9 deletions

View file

@ -9,6 +9,7 @@ use Icinga\Module\Businessprocess\BpConfig;
use Icinga\Module\Businessprocess\BpNode;
use Icinga\Module\Businessprocess\HostNode;
use Icinga\Module\Businessprocess\Node;
use Icinga\Module\Businessprocess\ProvidedHook\Icingadb\IcingadbSupport;
use Icinga\Module\Businessprocess\State\IcingaDbState;
use Icinga\Module\Businessprocess\State\MonitoringState;
use Icinga\Module\Businessprocess\Storage\LegacyStorage;
@ -133,7 +134,12 @@ class ProcessCommand extends Command
/** @var BpNode $node */
try {
$node = $bp->getNode($nodeName);
MonitoringState::apply($bp);
if ($bp->getBackendName() === '_icingadb' || IcingadbSupport::useIcingaDbAsBackend()) {
IcingaDbState::apply($bp);
} else {
MonitoringState::apply($bp);
}
if ($bp->hasErrors()) {
Logger::error("Checking Business Process '%s' failed: %s\n", $name, $bp->getErrors());

View file

@ -2,6 +2,7 @@
namespace Icinga\Module\Businessprocess\Controllers;
use Icinga\Module\Businessprocess\ProvidedHook\Icingadb\IcingadbSupport;
use Icinga\Module\Businessprocess\Renderer\Breadcrumb;
use Icinga\Module\Businessprocess\Renderer\TileRenderer;
use Icinga\Module\Businessprocess\Simulation;
@ -82,7 +83,7 @@ class NodeController extends Controller
if (empty($parents)) {
continue;
}
if ($config->getBackendName() === '_icingadb') {
if ($config->getBackendName() === '_icingadb' || IcingadbSupport::useIcingaDbAsBackend()) {
IcingaDbState::apply($config);
} else {
MonitoringState::apply($config);

View file

@ -6,6 +6,7 @@ use Icinga\Date\DateFormatter;
use Icinga\Module\Businessprocess\BpConfig;
use Icinga\Module\Businessprocess\BpNode;
use Icinga\Module\Businessprocess\Node;
use Icinga\Module\Businessprocess\ProvidedHook\Icingadb\IcingadbSupport;
use Icinga\Module\Businessprocess\Renderer\Breadcrumb;
use Icinga\Module\Businessprocess\Renderer\Renderer;
use Icinga\Module\Businessprocess\Renderer\TileRenderer;
@ -82,7 +83,7 @@ class ProcessController extends Controller
$bp = $this->loadModifiedBpConfig();
$node = $this->getNode($bp);
if ($bp->getBackendName() === '_icingadb') {
if ($bp->getBackendName() === '_icingadb' || IcingadbSupport::useIcingaDbAsBackend()) {
IcingaDbState::apply($bp);
} else {
MonitoringState::apply($bp);

View file

@ -5,6 +5,7 @@ namespace Icinga\Module\Businessprocess\Common;
use Icinga\Data\Filter\Filter;
use Icinga\Module\Businessprocess\IcingaDbObject;
use Icinga\Module\Businessprocess\MonitoringRestrictions;
use Icinga\Module\Businessprocess\ProvidedHook\Icingadb\IcingadbSupport;
trait EnumList
{
@ -133,6 +134,6 @@ trait EnumList
protected function useIcingaDbBackend()
{
return $this->backendName === '_icingadb';
return $this->backendName === '_icingadb' || IcingadbSupport::useIcingaDbAsBackend();
}
}

View file

@ -2,6 +2,7 @@
namespace Icinga\Module\Businessprocess;
use Icinga\Module\Businessprocess\ProvidedHook\Icingadb\IcingadbSupport;
use Icinga\Module\Businessprocess\Web\Url;
use ipl\Html\Html;
@ -56,9 +57,9 @@ class HostNode extends MonitoredNode
'host' => $this->getHostname(),
);
if ($this->getBpConfig()->hasBackendName()) {
if ($this->getBpConfig()->hasBackendName() || IcingadbSupport::useIcingaDbAsBackend()) {
$backendName = $this->getBpConfig()->getBackendName();
if ($backendName === '_icingadb') {
if ($backendName === '_icingadb' || IcingadbSupport::useIcingaDbAsBackend()) {
$params['icingadb'] = 1;
} else {
$params['backend'] = $this->getBpConfig()->getBackendName();

View file

@ -2,6 +2,7 @@
namespace Icinga\Module\Businessprocess;
use Icinga\Module\Businessprocess\ProvidedHook\Icingadb\IcingadbSupport;
use Icinga\Module\Businessprocess\Web\Url;
class ServiceNode extends MonitoredNode
@ -75,9 +76,10 @@ class ServiceNode extends MonitoredNode
'service' => $this->getServiceDescription()
);
if ($this->getBpConfig()->hasBackendName()) {
if ($this->getBpConfig()->hasBackendName() || IcingadbSupport::useIcingaDbAsBackend()) {
$backendName = $this->getBpConfig()->getBackendName();
if ($backendName === '_icingadb') {
if ($backendName === '_icingadb' || IcingadbSupport::useIcingaDbAsBackend()) {
$params['icingadb'] = 1;
} else {
$params['backend'] = $this->getBpConfig()->getBackendName();

View file

@ -3,6 +3,7 @@
namespace Icinga\Module\Businessprocess\Web\Component;
use Icinga\Authentication\Auth;
use Icinga\Module\Businessprocess\ProvidedHook\Icingadb\IcingadbSupport;
use Icinga\Module\Businessprocess\State\IcingaDbState;
use Icinga\Module\Businessprocess\State\MonitoringState;
use Icinga\Module\Businessprocess\Storage\Storage;
@ -92,7 +93,7 @@ class Dashboard extends BaseHtmlElement
}
$bp = $storage->loadProcess($name);
if ($bp->getBackendName() === '_icingadb') {
if ($bp->getBackendName() === '_icingadb' || IcingadbSupport::useIcingaDbAsBackend()) {
IcingaDbState::apply($bp);
} else {
MonitoringState::apply($bp);