mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
Relocate Backend classes
This commit is contained in:
parent
9baa3c4341
commit
604667ca65
@ -1,10 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Icinga\Module\Director\Backend;
|
namespace Icinga\Module\Director\Integration;
|
||||||
|
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
|
|
||||||
interface MonitorBackend
|
interface BackendInterface
|
||||||
{
|
{
|
||||||
public function isAvailable(): bool;
|
public function isAvailable(): bool;
|
||||||
|
|
@ -1,10 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Icinga\Module\Director\Backend;
|
namespace Icinga\Module\Director\Integration\Icingadb;
|
||||||
|
|
||||||
use gipfl\IcingaWeb2\Link;
|
use gipfl\IcingaWeb2\Link;
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Data\Filter\Filter as DataFilter;
|
use Icinga\Data\Filter\Filter as DataFilter;
|
||||||
|
use Icinga\Module\Director\Integration\BackendInterface;
|
||||||
use Icinga\Module\Director\Objects\IcingaHost;
|
use Icinga\Module\Director\Objects\IcingaHost;
|
||||||
use Icinga\Module\Icingadb\Common\Auth;
|
use Icinga\Module\Icingadb\Common\Auth;
|
||||||
use Icinga\Module\Icingadb\Common\Database;
|
use Icinga\Module\Icingadb\Common\Database;
|
||||||
@ -14,7 +15,7 @@ use Icinga\Module\Icingadb\Redis\VolatileStateResults;
|
|||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
use ipl\Stdlib\Filter;
|
use ipl\Stdlib\Filter;
|
||||||
|
|
||||||
class MonitorBackendIcingadb implements MonitorBackend
|
class IcingadbBackend implements BackendInterface
|
||||||
{
|
{
|
||||||
use Database;
|
use Database;
|
||||||
use Auth;
|
use Auth;
|
@ -10,11 +10,11 @@ use Icinga\Exception\ConfigurationError;
|
|||||||
use Icinga\Module\Director\Auth\MonitoringRestriction;
|
use Icinga\Module\Director\Auth\MonitoringRestriction;
|
||||||
use Icinga\Module\Director\Auth\Permission;
|
use Icinga\Module\Director\Auth\Permission;
|
||||||
use Icinga\Module\Director\Auth\Restriction;
|
use Icinga\Module\Director\Auth\Restriction;
|
||||||
use Icinga\Module\Director\Backend\MonitorBackend;
|
use Icinga\Module\Director\Integration\BackendInterface;
|
||||||
use Icinga\Module\Monitoring\Backend\MonitoringBackend;
|
use Icinga\Module\Monitoring\Backend\MonitoringBackend;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
|
|
||||||
class Monitoring implements MonitorBackend
|
class Monitoring implements BackendInterface
|
||||||
{
|
{
|
||||||
/** @var ?MonitoringBackend */
|
/** @var ?MonitoringBackend */
|
||||||
protected $backend;
|
protected $backend;
|
||||||
|
@ -4,8 +4,8 @@ namespace Icinga\Module\Director\ProvidedHook\Icingadb;
|
|||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
use Icinga\Module\Director\Backend\MonitorBackendIcingadb;
|
|
||||||
use Icinga\Module\Director\Db;
|
use Icinga\Module\Director\Db;
|
||||||
|
use Icinga\Module\Director\Integration\Icingadb\IcingadbBackend;
|
||||||
use Icinga\Module\Director\Objects\IcingaHost;
|
use Icinga\Module\Director\Objects\IcingaHost;
|
||||||
use Icinga\Module\Director\Util;
|
use Icinga\Module\Director\Util;
|
||||||
use Icinga\Module\Icingadb\Hook\HostActionsHook;
|
use Icinga\Module\Icingadb\Hook\HostActionsHook;
|
||||||
@ -44,7 +44,7 @@ class HostActions extends HostActionsHook
|
|||||||
$allowEdit = true;
|
$allowEdit = true;
|
||||||
}
|
}
|
||||||
if (Util::hasPermission('director/monitoring/hosts')) {
|
if (Util::hasPermission('director/monitoring/hosts')) {
|
||||||
$backend = new MonitorBackendIcingadb();
|
$backend = new IcingadbBackend();
|
||||||
if ($backend->isAvailable() && $backend->canModifyHost($hostname)) {
|
if ($backend->isAvailable() && $backend->canModifyHost($hostname)) {
|
||||||
$allowEdit = IcingaHost::exists($hostname, $db);
|
$allowEdit = IcingaHost::exists($hostname, $db);
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@ namespace Icinga\Module\Director\ProvidedHook\Icingadb;
|
|||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use Icinga\Application\Config;
|
use Icinga\Application\Config;
|
||||||
use Icinga\Module\Director\Backend\MonitorBackendIcingadb;
|
|
||||||
use Icinga\Module\Director\Db;
|
use Icinga\Module\Director\Db;
|
||||||
|
use Icinga\Module\Director\Integration\Icingadb\IcingadbBackend;
|
||||||
use Icinga\Module\Director\Objects\IcingaHost;
|
use Icinga\Module\Director\Objects\IcingaHost;
|
||||||
use Icinga\Module\Director\Util;
|
use Icinga\Module\Director\Util;
|
||||||
use Icinga\Module\Icingadb\Hook\ServiceActionsHook;
|
use Icinga\Module\Icingadb\Hook\ServiceActionsHook;
|
||||||
@ -56,7 +56,7 @@ class ServiceActions extends ServiceActionsHook
|
|||||||
if (Util::hasPermission('director/hosts')) {
|
if (Util::hasPermission('director/hosts')) {
|
||||||
$title = mt('director', 'Modify');
|
$title = mt('director', 'Modify');
|
||||||
} elseif (Util::hasPermission('director/monitoring/services')) {
|
} elseif (Util::hasPermission('director/monitoring/services')) {
|
||||||
$backend = new MonitorBackendIcingadb();
|
$backend = new IcingadbBackend();
|
||||||
if ($backend->isAvailable()
|
if ($backend->isAvailable()
|
||||||
&& $backend->canModifyService($hostname, $serviceName)
|
&& $backend->canModifyService($hostname, $serviceName)
|
||||||
) {
|
) {
|
||||||
|
@ -4,13 +4,12 @@ namespace Icinga\Module\Director\Web\Controller;
|
|||||||
|
|
||||||
use gipfl\Translation\StaticTranslator;
|
use gipfl\Translation\StaticTranslator;
|
||||||
use Icinga\Application\Benchmark;
|
use Icinga\Application\Benchmark;
|
||||||
use Icinga\Application\Icinga;
|
|
||||||
use Icinga\Application\Modules\Module;
|
use Icinga\Application\Modules\Module;
|
||||||
use Icinga\Data\Paginatable;
|
use Icinga\Data\Paginatable;
|
||||||
use Icinga\Exception\NotFoundError;
|
use Icinga\Exception\NotFoundError;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
use Icinga\Module\Director\Backend\MonitorBackend;
|
use Icinga\Module\Director\Integration\Icingadb\IcingadbBackend;
|
||||||
use Icinga\Module\Director\Backend\MonitorBackendIcingadb;
|
use Icinga\Module\Director\Integration\BackendInterface;
|
||||||
use Icinga\Module\Director\Integration\MonitoringModule\Monitoring;
|
use Icinga\Module\Director\Integration\MonitoringModule\Monitoring;
|
||||||
use Icinga\Module\Director\Web\Controller\Extension\CoreApi;
|
use Icinga\Module\Director\Web\Controller\Extension\CoreApi;
|
||||||
use Icinga\Module\Director\Web\Controller\Extension\DirectorDb;
|
use Icinga\Module\Director\Web\Controller\Extension\DirectorDb;
|
||||||
@ -40,7 +39,7 @@ abstract class ActionController extends Controller implements ControlsAndContent
|
|||||||
/** @var UrlParams Hint for IDE, somehow does not work in web */
|
/** @var UrlParams Hint for IDE, somehow does not work in web */
|
||||||
protected $params;
|
protected $params;
|
||||||
|
|
||||||
/** @var MonitorBackend */
|
/** @var BackendInterface */
|
||||||
private $backend;
|
private $backend;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -244,13 +243,13 @@ abstract class ActionController extends Controller implements ControlsAndContent
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return MonitorBackend
|
* @return BackendInterface
|
||||||
*/
|
*/
|
||||||
protected function backend()
|
protected function backend(): BackendInterface
|
||||||
{
|
{
|
||||||
if ($this->backend === null) {
|
if ($this->backend === null) {
|
||||||
if (Module::exists('icingadb')) {
|
if (Module::exists('icingadb')) {
|
||||||
$this->backend = new MonitorBackendIcingadb();
|
$this->backend = new IcingadbBackend();
|
||||||
} else {
|
} else {
|
||||||
$this->backend = new Monitoring($this->Auth());
|
$this->backend = new Monitoring($this->Auth());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user