Replace class `Backend` use with `MonitoringBackend` and remove class `Backend`

This commit is contained in:
Sukhwinder Dhillon 2022-05-30 11:21:48 +02:00 committed by Johannes Meyer
parent 0db42b32e6
commit 3b04a0489e
9 changed files with 18 additions and 28 deletions

View File

@ -52,6 +52,7 @@ v2.6 to v2.8 requires to follow the instructions for v2.7 too.
+ `Icinga\Web\Hook\TicketHook`: Use `Icinga\Application\Hook\TicketHook` instead. + `Icinga\Web\Hook\TicketHook`: Use `Icinga\Application\Hook\TicketHook` instead.
+ `Icinga\Web\Hook\GrapherHook`: Use `Icinga\Application\Hook\GrapherHook` instead. + `Icinga\Web\Hook\GrapherHook`: Use `Icinga\Application\Hook\GrapherHook` instead.
+ `Icinga\Module\Monitoring\Environment`: Not in use. + `Icinga\Module\Monitoring\Environment`: Not in use.
+ `Icinga\Module\Monitoring\Backend`: Use `Icinga\Module\Monitoring\Backend\MonitoringBackend` instead.
* All the following deprecated js classes and methods are removed: * All the following deprecated js classes and methods are removed:

View File

@ -3,7 +3,7 @@
namespace Icinga\Module\Monitoring\Clicommands; namespace Icinga\Module\Monitoring\Clicommands;
use Icinga\Module\Monitoring\Backend; use Icinga\Module\Monitoring\Backend\MonitoringBackend;
use Icinga\Module\Monitoring\Cli\CliUtils; use Icinga\Module\Monitoring\Cli\CliUtils;
use Icinga\Date\DateFormatter; use Icinga\Date\DateFormatter;
use Icinga\Cli\Command; use Icinga\Cli\Command;
@ -25,7 +25,7 @@ class ListCommand extends Command
public function init() public function init()
{ {
$this->backend = Backend::instance($this->params->shift('backend')); $this->backend = MonitoringBackend::instance($this->params->shift('backend'));
$this->dumpSql = $this->params->shift('showsql'); $this->dumpSql = $this->params->shift('showsql');
} }

View File

@ -8,10 +8,10 @@ use Icinga\Data\ResourceFactory;
use Icinga\Exception\ConfigurationError; use Icinga\Exception\ConfigurationError;
use Icinga\Exception\NotFoundError; use Icinga\Exception\NotFoundError;
use Icinga\Forms\ConfirmRemovalForm; use Icinga\Forms\ConfirmRemovalForm;
use Icinga\Module\Monitoring\Backend\MonitoringBackend;
use Icinga\Module\Monitoring\Forms\Config\TransportReorderForm; use Icinga\Module\Monitoring\Forms\Config\TransportReorderForm;
use Icinga\Web\Controller; use Icinga\Web\Controller;
use Icinga\Web\Notification; use Icinga\Web\Notification;
use Icinga\Module\Monitoring\Backend;
use Icinga\Module\Monitoring\Forms\Config\BackendConfigForm; use Icinga\Module\Monitoring\Forms\Config\BackendConfigForm;
use Icinga\Module\Monitoring\Forms\Config\SecurityConfigForm; use Icinga\Module\Monitoring\Forms\Config\SecurityConfigForm;
use Icinga\Module\Monitoring\Forms\Config\TransportConfigForm; use Icinga\Module\Monitoring\Forms\Config\TransportConfigForm;
@ -215,7 +215,7 @@ class ConfigController extends Controller
$form->setTitle(sprintf($this->translate('Edit Command Transport %s'), $transportName)); $form->setTitle(sprintf($this->translate('Edit Command Transport %s'), $transportName));
$form->setIniConfig($this->Config('commandtransports')); $form->setIniConfig($this->Config('commandtransports'));
$form->setInstanceNames( $form->setInstanceNames(
Backend::instance()->select()->from('instance', array('instance_name'))->fetchColumn() MonitoringBackend::instance()->select()->from('instance', array('instance_name'))->fetchColumn()
); );
$form->setOnSuccess(function (TransportConfigForm $form) use ($transportName) { $form->setOnSuccess(function (TransportConfigForm $form) use ($transportName) {
try { try {
@ -259,7 +259,7 @@ class ConfigController extends Controller
$form->setTitle($this->translate('Create New Command Transport')); $form->setTitle($this->translate('Create New Command Transport'));
$form->setIniConfig($this->Config('commandtransports')); $form->setIniConfig($this->Config('commandtransports'));
$form->setInstanceNames( $form->setInstanceNames(
Backend::instance()->select()->from('instance', array('instance_name'))->fetchColumn() MonitoringBackend::instance()->select()->from('instance', array('instance_name'))->fetchColumn()
); );
$form->setOnSuccess(function (TransportConfigForm $form) { $form->setOnSuccess(function (TransportConfigForm $form) {
try { try {

View File

@ -3,12 +3,12 @@
namespace Icinga\Module\Monitoring\Controllers; namespace Icinga\Module\Monitoring\Controllers;
use Icinga\Module\Monitoring\Backend\MonitoringBackend;
use Icinga\Security\SecurityException; use Icinga\Security\SecurityException;
use Icinga\Util\GlobFilter; use Icinga\Util\GlobFilter;
use Icinga\Web\Form; use Icinga\Web\Form;
use Zend_Form; use Zend_Form;
use Icinga\Data\Filter\Filter; use Icinga\Data\Filter\Filter;
use Icinga\Module\Monitoring\Backend;
use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Controller;
use Icinga\Module\Monitoring\DataView\DataView; use Icinga\Module\Monitoring\DataView\DataView;
use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm;
@ -34,7 +34,7 @@ class ListController extends Controller
/** /**
* Overwrite the backend to use (used for testing) * Overwrite the backend to use (used for testing)
* *
* @param Backend $backend The Backend that should be used for querying * @param MonitoringBackend $backend The Backend that should be used for querying
*/ */
public function setBackend($backend) public function setBackend($backend)
{ {

View File

@ -4,7 +4,7 @@
namespace Icinga\Module\Monitoring\Controllers; namespace Icinga\Module\Monitoring\Controllers;
use Icinga\Data\Filter\FilterEqual; use Icinga\Data\Filter\FilterEqual;
use Icinga\Module\Monitoring\Backend; use Icinga\Module\Monitoring\Backend\MonitoringBackend;
use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\Controller;
use Icinga\Security\SecurityException; use Icinga\Security\SecurityException;
use Icinga\Web\Url; use Icinga\Web\Url;
@ -17,7 +17,7 @@ use Icinga\Web\Url;
class ShowController extends Controller class ShowController extends Controller
{ {
/** /**
* @var Backend * @var MonitoringBackend
*/ */
protected $backend; protected $backend;

View File

@ -1,12 +0,0 @@
<?php
/* Icinga Web 2 | (c) 2013 Icinga Development Team | GPLv2+ */
// TODO: obsolete, remove once MonitoringBackend is in use everywhere
namespace Icinga\Module\Monitoring;
use Icinga\Module\Monitoring\Backend\MonitoringBackend;
class Backend extends MonitoringBackend
{
}

View File

@ -9,6 +9,7 @@ use Icinga\Exception\QueryException;
use Icinga\Data\Filter\Filter; use Icinga\Data\Filter\Filter;
use Icinga\Data\Filterable; use Icinga\Data\Filterable;
use Icinga\File\Csv; use Icinga\File\Csv;
use Icinga\Module\Monitoring\Backend\MonitoringBackend;
use Icinga\Module\Monitoring\Data\CustomvarProtectionIterator; use Icinga\Module\Monitoring\Data\CustomvarProtectionIterator;
use Icinga\Util\Json; use Icinga\Util\Json;
use Icinga\Web\Controller as IcingaWebController; use Icinga\Web\Controller as IcingaWebController;
@ -22,13 +23,13 @@ class Controller extends IcingaWebController
/** /**
* The backend used for this controller * The backend used for this controller
* *
* @var Backend * @var MonitoringBackend
*/ */
protected $backend; protected $backend;
protected function moduleInit() protected function moduleInit()
{ {
$this->backend = Backend::instance($this->_getParam('backend')); $this->backend = MonitoringBackend::instance($this->_getParam('backend'));
$this->view->url = Url::fromRequest(); $this->view->url = Url::fromRequest();
} }

View File

@ -5,7 +5,7 @@ namespace Icinga\Module\Monitoring\ProvidedHook;
use Icinga\Application\Hook\HealthHook; use Icinga\Application\Hook\HealthHook;
use Icinga\Date\DateFormatter; use Icinga\Date\DateFormatter;
use Icinga\Module\Monitoring\Backend; use Icinga\Module\Monitoring\Backend\MonitoringBackend;
use ipl\Web\Url; use ipl\Web\Url;
class Health extends HealthHook class Health extends HealthHook
@ -25,7 +25,7 @@ class Health extends HealthHook
public function checkHealth() public function checkHealth()
{ {
$backendName = Backend::instance()->getName(); $backendName = MonitoringBackend::instance()->getName();
$programStatus = $this->getProgramStatus(); $programStatus = $this->getProgramStatus();
if ($programStatus === false) { if ($programStatus === false) {
$this->setState(self::STATE_UNKNOWN); $this->setState(self::STATE_UNKNOWN);
@ -55,7 +55,7 @@ class Health extends HealthHook
protected function getProgramStatus() protected function getProgramStatus()
{ {
if ($this->programStatus === null) { if ($this->programStatus === null) {
$this->programStatus = Backend::instance()->select() $this->programStatus = MonitoringBackend::instance()->select()
->from('programstatus', [ ->from('programstatus', [
'program_version', 'program_version',
'status_update_time', 'status_update_time',

View File

@ -9,7 +9,7 @@ require_once realpath(dirname(__FILE__) . '/../../../../../test/php/bootstrap.ph
use Icinga\Application\Config; use Icinga\Application\Config;
use Icinga\Data\ConfigObject; use Icinga\Data\ConfigObject;
use Icinga\Module\Monitoring\Backend; use Icinga\Module\Monitoring\Backend\MonitoringBackend;
use Icinga\Test\BaseTestCase; use Icinga\Test\BaseTestCase;
use Mockery; use Mockery;
@ -53,7 +53,7 @@ class Bug7043Test extends BaseTestCase
) )
))); )));
$defaultBackend = Backend::instance(); $defaultBackend = MonitoringBackend::instance();
$this->assertEquals('backendName', $defaultBackend->getName(), 'Default backend has name set'); $this->assertEquals('backendName', $defaultBackend->getName(), 'Default backend has name set');
} }