2015-09-30 08:41:51 +02:00
|
|
|
<?php
|
|
|
|
|
2015-10-20 22:34:04 +02:00
|
|
|
namespace Icinga\Module\Director\Controllers;
|
|
|
|
|
2015-09-30 08:41:51 +02:00
|
|
|
use Icinga\Module\Director\Web\Controller\ActionController;
|
|
|
|
|
2015-10-20 22:34:04 +02:00
|
|
|
class InspectController extends ActionController
|
2015-09-30 08:41:51 +02:00
|
|
|
{
|
|
|
|
public function typesAction()
|
|
|
|
{
|
2015-12-17 10:49:10 +01:00
|
|
|
$this->view->title = sprintf(
|
|
|
|
$this->translate('Icinga2 Objects: %s'),
|
|
|
|
$this->view->endpoint
|
|
|
|
);
|
2015-09-30 08:41:51 +02:00
|
|
|
$api = $this->api();
|
|
|
|
$types = $api->getTypes();
|
|
|
|
$rootNodes = array();
|
|
|
|
foreach ($types as $name => $type) {
|
|
|
|
if (property_exists($type, 'base')) {
|
|
|
|
$base = $type->base;
|
|
|
|
if (! property_exists($types[$base], 'children')) {
|
|
|
|
$types[$base]->children = array();
|
|
|
|
}
|
|
|
|
|
|
|
|
$types[$base]->children[$name] = $type;
|
|
|
|
} else {
|
|
|
|
$rootNodes[$name] = $type;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->view->types = $rootNodes;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function typeAction()
|
|
|
|
{
|
2015-10-16 22:57:48 +02:00
|
|
|
$typeName = $this->params->get('name');
|
2015-12-17 10:49:10 +01:00
|
|
|
$this->view->title = sprintf(
|
|
|
|
$this->translate('Object type "%s"'),
|
|
|
|
$typeName
|
|
|
|
);
|
2015-10-16 22:57:48 +02:00
|
|
|
$this->view->type = $type = $this->api()->getType($typeName);
|
|
|
|
if ($type->abstract) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! empty($type->fields)) {
|
2015-11-26 18:54:10 +01:00
|
|
|
$this->view->objects = $this->api()->listObjects(
|
2015-10-16 22:57:48 +02:00
|
|
|
$typeName,
|
2015-11-09 18:32:46 +01:00
|
|
|
$type->plural_name
|
2015-10-16 22:57:48 +02:00
|
|
|
);
|
|
|
|
}
|
2015-09-30 08:41:51 +02:00
|
|
|
}
|
|
|
|
|
2015-11-26 18:54:10 +01:00
|
|
|
public function objectAction()
|
|
|
|
{
|
|
|
|
$this->view->object = $this->api()->getObject(
|
|
|
|
$this->params->get('name'),
|
|
|
|
$this->params->get('plural')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-11-26 11:01:15 +01:00
|
|
|
public function commandsAction()
|
|
|
|
{
|
2015-12-02 03:37:10 +01:00
|
|
|
$db = $this->db();
|
|
|
|
echo '<pre>';
|
|
|
|
foreach ($this->api()->setDb($db)->getCheckCommandObjects() as $object) {
|
|
|
|
if (! $object::exists($object->object_name, $db)) {
|
|
|
|
// var_dump($object->store());
|
|
|
|
echo $object;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo '</pre>';
|
|
|
|
exit;
|
2015-11-26 11:01:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function zonesAction()
|
|
|
|
{
|
|
|
|
$db = $this->db();
|
|
|
|
echo '<pre>';
|
|
|
|
foreach ($this->api()->setDb($db)->getZoneObjects() as $zone) {
|
|
|
|
if (! $zone::exists($zone->object_name, $db)) {
|
2015-12-02 03:37:10 +01:00
|
|
|
// var_dump($zone->store());
|
2015-11-26 11:01:15 +01:00
|
|
|
echo $zone;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
echo '</pre>';
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2015-10-16 23:00:30 +02:00
|
|
|
public function statusAction()
|
|
|
|
{
|
|
|
|
$this->view->status = $status = $this->api()->getStatus();
|
2016-02-26 12:42:21 +01:00
|
|
|
print_r($status);
|
|
|
|
exit;
|
2015-10-16 23:00:30 +02:00
|
|
|
}
|
2015-12-17 10:49:10 +01:00
|
|
|
|
2016-02-17 16:40:43 +01:00
|
|
|
protected function api($endpointName = null)
|
2015-12-17 10:49:10 +01:00
|
|
|
{
|
|
|
|
$this->view->endpoint = $this->params->get('endpoint');
|
2016-02-09 20:38:56 +01:00
|
|
|
if ($this->view->endpoint === null) {
|
|
|
|
$this->view->endpoint = $this->db()->getDeploymentEndpointName();
|
|
|
|
}
|
|
|
|
|
2016-02-17 16:40:43 +01:00
|
|
|
return parent::api($this->view->endpoint);
|
2015-12-17 10:49:10 +01:00
|
|
|
}
|
2015-09-30 08:41:51 +02:00
|
|
|
}
|