parent
55d84e03d4
commit
2ca7f26b49
|
@ -208,7 +208,7 @@ class SelfServiceController extends ActionController
|
|||
$params['download_url'] = $settings->get('self-service/download_url');
|
||||
$params['agent_version'] = $settings->get('self-service/agent_version');
|
||||
$params['allow_updates'] = $settings->get('self-service/allow_updates') === 'y';
|
||||
|
||||
$params['agent_listen_port'] = $host->getAgentListenPort();
|
||||
if ($hashes = $settings->get('self-service/installer_hashes')) {
|
||||
$params['installer_hashes'] = json_decode($hashes);
|
||||
}
|
||||
|
@ -263,6 +263,16 @@ class SelfServiceController extends ActionController
|
|||
return;
|
||||
}
|
||||
|
||||
$params['agent_add_firewall_rule'] = $host
|
||||
->getSingleResolvedProperty('master_should_connect') === 'y';
|
||||
|
||||
$zdb = $db->getDbAdapter();
|
||||
$params['global_zones'] = $zdb->fetchCol(
|
||||
$zdb->select()->from('icinga_zone', 'object_name')
|
||||
->where('disabled = ?', 'n')
|
||||
->where('is_global = ?', 'y')
|
||||
->order('object_name')
|
||||
);
|
||||
|
||||
$zone = IcingaZone::load($zoneName, $db);
|
||||
$master = $db->getDeploymentEndpoint();
|
||||
|
|
|
@ -49,7 +49,8 @@ class SelfServiceSettingsForm extends DirectorForm
|
|||
),
|
||||
'multiOptions' => [
|
||||
null => $this->translate('- no automatic installation -'),
|
||||
'director' => $this->translate('Download via the Icinga Director'),
|
||||
// TODO: not yet
|
||||
// 'director' => $this->translate('Download via the Icinga Director'),
|
||||
'icinga' => $this->translate('Download from packages.icinga.com'),
|
||||
'url' => $this->translate('Download from a custom url'),
|
||||
'file' => $this->translate('Use a local file or network share'),
|
||||
|
@ -67,7 +68,7 @@ class SelfServiceSettingsForm extends DirectorForm
|
|||
$this->addInstallSettings($downloadType, $settings);
|
||||
}
|
||||
|
||||
$this->addBoolean('flush_api_dir', [
|
||||
$this->addEventuallyConfiguredBoolean('flush_api_dir', [
|
||||
'label' => $this->translate('Flush API directory'),
|
||||
'description' => $this->translate(
|
||||
'In case the Icinga Agent will accept configuration from the parent'
|
||||
|
@ -76,7 +77,7 @@ class SelfServiceSettingsForm extends DirectorForm
|
|||
. ' will be flushed before an eventual restart of the Icinga 2 Agent'
|
||||
),
|
||||
'required' => true,
|
||||
], true);
|
||||
]);
|
||||
}
|
||||
|
||||
protected function addInstallSettings($downloadType, Settings $settings)
|
||||
|
@ -151,31 +152,51 @@ class SelfServiceSettingsForm extends DirectorForm
|
|||
'value' => $hashes,
|
||||
]);
|
||||
|
||||
$this->addBoolean('allow_updates', [
|
||||
'label' => $this->translate('Allow Updates'),
|
||||
$this->addElement('extensibleSet', 'installer_hashes', [
|
||||
'label' => $this->translate('Installer Hashes'),
|
||||
'description' => $this->translate(
|
||||
'To ensure downloaded packages are build by the Icinga Team'
|
||||
. ' and not compromised by third parties, you will be able'
|
||||
. ' to provide an array of SHA1 hashes here. In case you have'
|
||||
. ' defined any hashses, the module will not continue with'
|
||||
. ' updating / installing the Agent in case the SHA1 hash of'
|
||||
. ' the downloaded MSI package is not matching one of the'
|
||||
. ' provided hashes of this setting'
|
||||
),
|
||||
'value' => $hashes,
|
||||
]);
|
||||
|
||||
$this->addElement('text', 'icinga_service_user', [
|
||||
'label' => $this->translate('Service User'),
|
||||
'description' => $this->translate(
|
||||
'The user that should run the Icinga 2 service on Windows.'
|
||||
),
|
||||
'value' => $settings->getStoredOrDefaultValue('self-service/icinga_service_user'),
|
||||
]);
|
||||
|
||||
$this->addEventuallyConfiguredBoolean('allow_updates', [
|
||||
'label' => $this->translate('Allow Updates'),
|
||||
'description' => $this->translate(
|
||||
'In case the Icinga 2 Agent is already installed on the system,'
|
||||
. ' this parameter will allow you to configure if you wish to'
|
||||
. ' upgrade / downgrade to a specified version with the as well.'
|
||||
),
|
||||
'value' => $settings->getStoredOrDefaultValue('self-service/allow_updates'),
|
||||
'required' => true,
|
||||
], true);
|
||||
]);
|
||||
|
||||
$this->addNscpSettings($settings);
|
||||
$this->addNscpSettings();
|
||||
}
|
||||
|
||||
protected function addNscpSettings(Settings $settings)
|
||||
protected function addNscpSettings()
|
||||
{
|
||||
$this->addBoolean('install_nsclient', [
|
||||
$this->addEventuallyConfiguredBoolean('install_nsclient', [
|
||||
'label' => $this->translate('Install NSClient++'),
|
||||
'description' => $this->translate(
|
||||
'Also install NSClient++. It can be used through the Icinga Agent'
|
||||
. ' and comes with a bunch of additional Check Plugins'
|
||||
),
|
||||
'value' => $settings->getStoredOrDefaultValue('self-service/install_nsclient'),
|
||||
'required' => true,
|
||||
], true);
|
||||
]);
|
||||
}
|
||||
|
||||
public static function create(Db $db, Settings $settings)
|
||||
|
@ -183,6 +204,34 @@ class SelfServiceSettingsForm extends DirectorForm
|
|||
return static::load()->setDb($db)->setSettings($settings);
|
||||
}
|
||||
|
||||
protected function addEventuallyConfiguredBoolean($name, $params)
|
||||
{
|
||||
$key = "self-service/$name";
|
||||
$value = $this->settings->getStoredValue($key);
|
||||
$params['value'] = $value;
|
||||
$params['multiOptions'] = $this->eventuallyConfiguredEnum($name, [
|
||||
'y' => $this->translate('Yes'),
|
||||
'n' => $this->translate('No'),
|
||||
]);
|
||||
|
||||
return $this->addElement('select', $name, $params);
|
||||
}
|
||||
|
||||
protected function eventuallyConfiguredEnum($name, $enum)
|
||||
{
|
||||
$key = "self-service/$name";
|
||||
$default = $this->settings->getDefaultValue($key);
|
||||
if ($default === null) {
|
||||
return [
|
||||
null => $this->translate('- please choose -')
|
||||
] + $enum;
|
||||
} else {
|
||||
return [
|
||||
null => sprintf($this->translate('%s (default)'), $enum[$default])
|
||||
] + $enum;
|
||||
}
|
||||
}
|
||||
|
||||
protected function setSentValue($key, $value)
|
||||
{
|
||||
$this->getRequest()->setPost($key, $value);
|
||||
|
|
|
@ -97,6 +97,19 @@ class IcingaEndpoint extends IcingaObject
|
|||
return parent::getRenderingZone($config);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getResolvedPort()
|
||||
{
|
||||
$port = $this->getSingleResolvedProperty('port');
|
||||
if (null === $port) {
|
||||
return 5665;
|
||||
} else {
|
||||
return (int) $port;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Use duration time renderer helper
|
||||
*
|
||||
|
|
|
@ -239,6 +239,17 @@ class IcingaHost extends IcingaObject
|
|||
$config->configFile($pre . 'agent_zones')->addObject($zone);
|
||||
}
|
||||
|
||||
public function getAgentListenPort()
|
||||
{
|
||||
$conn = $this->connection;
|
||||
$name = $this->getObjectName();
|
||||
if (IcingaEndpoint::exists($name, $conn)) {
|
||||
return IcingaEndpoint::load($name, $conn)->getResolvedPort();
|
||||
} else {
|
||||
return 5665;
|
||||
}
|
||||
}
|
||||
|
||||
public function hasAnyOverridenServiceVars()
|
||||
{
|
||||
$varname = $this->getServiceOverrivesVarname();
|
||||
|
|
Loading…
Reference in New Issue