diff --git a/modules/monitoring/library/Monitoring/Controller.php b/modules/monitoring/library/Monitoring/Controller.php index 6406c42fa..49be32eca 100644 --- a/modules/monitoring/library/Monitoring/Controller.php +++ b/modules/monitoring/library/Monitoring/Controller.php @@ -29,9 +29,6 @@ namespace Icinga\Module\Monitoring; -use Icinga\Application\Config as IcingaConfig; -use Icinga\Data\ResourceFactory; -use Icinga\Exception\ConfigurationError; use Icinga\File\Csv; use Icinga\Web\Controller\ActionController; @@ -74,52 +71,5 @@ class Controller extends ActionController exit; } } - - /** - * Create a backend - * - * @param string $backendName Name of the backend or null for creating the default backend which is the first INI - * configuration entry not being disabled - * - * @return Backend - * @throws ConfigurationError When no backend has been configured or all backends are disabled or the - * configuration for the requested backend does either not exist or it's disabled - */ - protected function createBackend($backendName = null) - { - $allBackends = array(); - $defaultBackend = null; - foreach (IcingaConfig::module('monitoring', 'backends') as $name => $config) { - if (!(bool) $config->get('disabled', false) && $defaultBackend === null) { - $defaultBackend = $config; - } - $allBackends[$name] = $config; - } - if (empty($allBackends)) { - throw new ConfigurationError('No backend has been configured'); - } - if ($defaultBackend === null) { - throw new ConfigurationError('All backends are disabled'); - } - if ($backendName === null) { - $backendConfig = $defaultBackend; - } else { - if (!array_key_exists($backendName, $allBackends)) { - throw new ConfigurationError('No configuration for backend ' . $backendName); - } - $backendConfig = $allBackends[$backendName]; - if ((bool) $backendConfig->get('disabled', false)) { - throw new ConfigurationError( - 'Configuration for backend ' . $backendName . ' available but backend is disabled' - ); - } - } - $resource = ResourceFactory::createResource(ResourceFactory::getResourceConfig($backendConfig->resource)); - if ($backendConfig->type === 'ido' && $resource->getDbType() !== 'oracle') { - // TODO(el): The resource should set the table prefix - $resource->setTablePrefix('icinga_'); - } - return new Backend($resource, $backendConfig->type); - } } // @codingStandardsIgnoreEnd