mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
InspectController: delegate api instantiation
This commit is contained in:
parent
e33d548d1b
commit
bf31f77961
@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
namespace Icinga\Module\Director\Controllers;
|
namespace Icinga\Module\Director\Controllers;
|
||||||
|
|
||||||
use Icinga\Module\Director\Core\CoreApi;
|
|
||||||
use Icinga\Module\Director\Core\RestApiClient;
|
|
||||||
use Icinga\Module\Director\Objects\IcingaEndpoint;
|
|
||||||
use Icinga\Module\Director\Web\Controller\ActionController;
|
use Icinga\Module\Director\Web\Controller\ActionController;
|
||||||
|
|
||||||
class InspectController extends ActionController
|
class InspectController extends ActionController
|
||||||
@ -95,18 +92,13 @@ class InspectController extends ActionController
|
|||||||
print_r($status); exit;
|
print_r($status); exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function api()
|
protected function api($endpointName = null)
|
||||||
{
|
{
|
||||||
$this->view->endpoint = $this->params->get('endpoint');
|
$this->view->endpoint = $this->params->get('endpoint');
|
||||||
if ($this->view->endpoint === null) {
|
if ($this->view->endpoint === null) {
|
||||||
$this->view->endpoint = $this->db()->getDeploymentEndpointName();
|
$this->view->endpoint = $this->db()->getDeploymentEndpointName();
|
||||||
}
|
}
|
||||||
|
|
||||||
$endpoint = IcingaEndpoint::load($this->view->endpoint, $this->db());
|
return parent::api($this->view->endpoint);
|
||||||
$apiconfig = $this->Config()->getSection('api');
|
|
||||||
$client = new RestApiClient($endpoint->host, $endpoint->port);
|
|
||||||
$client->setCredentials($apiconfig->get('username'), $apiconfig->get('password'));
|
|
||||||
$api = new CoreApi($client);
|
|
||||||
return $api;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user