SelfService: add endpoints_config

refs #486
This commit is contained in:
Thomas Gelf 2017-07-13 16:39:48 +02:00
parent 4830a2a879
commit c381fb76f0
1 changed files with 20 additions and 3 deletions

View File

@ -6,6 +6,7 @@ use Exception;
use Icinga\Exception\NotFoundError;
use Icinga\Exception\ProgrammingError;
use Icinga\Module\Director\Forms\IcingaHostSelfServiceForm;
use Icinga\Module\Director\Objects\IcingaEndpoint;
use Icinga\Module\Director\Objects\IcingaHost;
use Icinga\Module\Director\Objects\IcingaZone;
use Icinga\Module\Director\Settings;
@ -292,16 +293,32 @@ class SelfServiceController extends ActionController
return;
}
$params['agent_add_firewall_rule'] = $host
->getSingleResolvedProperty('master_should_connect') === 'y';
$masterConnectsToAgent = $host->getSingleResolvedProperty(
'master_should_connect'
) === 'y';
$params['agent_add_firewall_rule'] = $masterConnectsToAgent;
$params['global_zones'] = $settings->get('self-service/global_zones');
$zone = IcingaZone::load($zoneName, $db);
$endpointNames = $zone->listEndpoints();
if (! $masterConnectsToAgent) {
$endpointsConfig = [];
foreach ($endpointNames as $endpointName) {
$endpoint = IcingaEndpoint::load($endpointName, $db);
$endpointsConfig[] = sprintf(
'%s;%s',
$endpoint->getSingleResolvedProperty('host'),
$endpoint->getResolvedPort()
);
}
$params['endpoints_config'] = $endpointsConfig;
}
$master = $db->getDeploymentEndpoint();
$params['parent_zone'] = $zoneName;
$params['ca_server'] = $master->getObjectName();
$params['parent_endpoints'] = $zone->listEndpoints();
$params['parent_endpoints'] = $endpointNames;
$params['accept_config'] = $host->getSingleResolvedProperty('accept_config')=== 'y';
}