diff --git a/application/clicommands/ProcessCommand.php b/application/clicommands/ProcessCommand.php index 541d97f..3b470b8 100644 --- a/application/clicommands/ProcessCommand.php +++ b/application/clicommands/ProcessCommand.php @@ -135,8 +135,8 @@ class ProcessCommand extends Command /** @var BpNode $node */ try { $node = $bp->getNode($nodeName); - if (Module::exists('icingadb') && - ($bp->getBackendName() === '_icingadb' || IcingadbSupport::useIcingaDbAsBackend()) + if (Module::exists('icingadb') + && (! $bp->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend()) ) { IcingaDbState::apply($bp); } else { diff --git a/application/controllers/NodeController.php b/application/controllers/NodeController.php index 0613109..8addc07 100644 --- a/application/controllers/NodeController.php +++ b/application/controllers/NodeController.php @@ -86,7 +86,7 @@ class NodeController extends Controller } if (Module::exists('icingadb') && - ($config->getBackendName() === '_icingadb' || IcingadbSupport::useIcingaDbAsBackend()) + (! $config->getBackendName() && IcingadbSupport::useIcingaDbAsBackend()) ) { IcingaDbState::apply($config); } else { diff --git a/application/controllers/ProcessController.php b/application/controllers/ProcessController.php index 272c671..475826f 100644 --- a/application/controllers/ProcessController.php +++ b/application/controllers/ProcessController.php @@ -85,7 +85,7 @@ class ProcessController extends Controller $node = $this->getNode($bp); if (Module::exists('icingadb') && - ($bp->getBackendName() === '_icingadb' || IcingadbSupport::useIcingaDbAsBackend()) + (! $bp->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend()) ) { IcingaDbState::apply($bp); } else { diff --git a/library/Businessprocess/BpConfig.php b/library/Businessprocess/BpConfig.php index e9089de..1e3f119 100644 --- a/library/Businessprocess/BpConfig.php +++ b/library/Businessprocess/BpConfig.php @@ -292,22 +292,13 @@ class BpConfig public function getBackend() { if ($this->backend === null) { - if ($this->getBackendName() === '_icingadb' || - (Module::exists('icingadb') && IcingadbSupport::useIcingaDbAsBackend()) - ) { - if (! Module::exists('icingadb')) { - throw new Exception('Icingadb module is not enabled.'); - } - + if (Module::exists('icingadb') + && (! $this->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend())) { $this->backend = IcingaDbObject::fetchDb(); } else { - if (! Module::exists('monitoring') && Module::exists('icingadb')) { - $this->backend = IcingaDbObject::fetchDb(); - } else { - $this->backend = MonitoringBackend::instance( - $this->getBackendName() - ); - } + $this->backend = MonitoringBackend::instance( + $this->getBackendName() + ); } } diff --git a/library/Businessprocess/Common/EnumList.php b/library/Businessprocess/Common/EnumList.php index 5a2a4ae..a1e5b56 100644 --- a/library/Businessprocess/Common/EnumList.php +++ b/library/Businessprocess/Common/EnumList.php @@ -160,7 +160,7 @@ trait EnumList protected function useIcingaDbBackend() { if (Module::exists('icingadb')) { - return $this->backendName === '_icingadb' || IcingadbSupport::useIcingaDbAsBackend(); + return ! $this->bp->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend(); } return false; diff --git a/library/Businessprocess/HostNode.php b/library/Businessprocess/HostNode.php index eccf1aa..b66f66f 100644 --- a/library/Businessprocess/HostNode.php +++ b/library/Businessprocess/HostNode.php @@ -2,10 +2,7 @@ namespace Icinga\Module\Businessprocess; -use Icinga\Application\Modules\Module; -use Icinga\Module\Businessprocess\ProvidedHook\Icingadb\IcingadbSupport; use Icinga\Module\Businessprocess\Web\Url; -use ipl\Html\Html; class HostNode extends MonitoredNode { @@ -58,18 +55,8 @@ class HostNode extends MonitoredNode 'host' => $this->getHostname(), ); - if ($this->getBpConfig()->hasBackendName() || - (Module::exists('icingadb') && IcingadbSupport::useIcingaDbAsBackend()) - ) { - $backendName = $this->getBpConfig()->getBackendName(); - - if (Module::exists('icingadb') && - ($backendName === '_icingadb' || IcingadbSupport::useIcingaDbAsBackend()) - ) { - $params['backend'] = '_icingadb'; - } else { - $params['backend'] = $this->getBpConfig()->getBackendName(); - } + if ($this->getBpConfig()->hasBackendName()) { + $params['backend'] = $this->getBpConfig()->getBackendName(); } return Url::fromPath('businessprocess/host/show', $params); diff --git a/library/Businessprocess/ServiceNode.php b/library/Businessprocess/ServiceNode.php index a0972a6..6160bce 100644 --- a/library/Businessprocess/ServiceNode.php +++ b/library/Businessprocess/ServiceNode.php @@ -2,8 +2,6 @@ namespace Icinga\Module\Businessprocess; -use Icinga\Application\Modules\Module; -use Icinga\Module\Businessprocess\ProvidedHook\Icingadb\IcingadbSupport; use Icinga\Module\Businessprocess\Web\Url; class ServiceNode extends MonitoredNode @@ -77,18 +75,8 @@ class ServiceNode extends MonitoredNode 'service' => $this->getServiceDescription() ); - if ($this->getBpConfig()->hasBackendName() || - (Module::exists('icingadb') && IcingadbSupport::useIcingaDbAsBackend()) - ) { - $backendName = $this->getBpConfig()->getBackendName(); - - if (Module::exists('icingadb') && - ($backendName === '_icingadb' || IcingadbSupport::useIcingaDbAsBackend()) - ) { - $params['backend'] = '_icingadb'; - } else { - $params['backend'] = $this->getBpConfig()->getBackendName(); - } + if ($this->getBpConfig()->hasBackendName()) { + $params['backend'] = $this->getBpConfig()->getBackendName(); } return Url::fromPath('businessprocess/service/show', $params); diff --git a/library/Businessprocess/Web/Component/Dashboard.php b/library/Businessprocess/Web/Component/Dashboard.php index 712c049..58506df 100644 --- a/library/Businessprocess/Web/Component/Dashboard.php +++ b/library/Businessprocess/Web/Component/Dashboard.php @@ -96,7 +96,7 @@ class Dashboard extends BaseHtmlElement $bp = $storage->loadProcess($name); if (Module::exists('icingadb') && - ($bp->getBackendName() === '_icingadb' || IcingadbSupport::useIcingaDbAsBackend()) + (! $bp->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend()) ) { IcingaDbState::apply($bp); } else {