mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-09-25 10:57:41 +02:00
parent
2ca7f26b49
commit
3574cec487
@ -15,10 +15,15 @@ use ipl\Html\Html;
|
|||||||
|
|
||||||
class SelfServiceController extends ActionController
|
class SelfServiceController extends ActionController
|
||||||
{
|
{
|
||||||
|
/** @var bool */
|
||||||
protected $isApified = true;
|
protected $isApified = true;
|
||||||
|
|
||||||
|
/** @var bool */
|
||||||
protected $requiresAuthentication = false;
|
protected $requiresAuthentication = false;
|
||||||
|
|
||||||
|
/** @var Settings */
|
||||||
|
protected $settings;
|
||||||
|
|
||||||
protected function assertApiPermission()
|
protected function assertApiPermission()
|
||||||
{
|
{
|
||||||
// no permission required, we'll check the API key
|
// no permission required, we'll check the API key
|
||||||
@ -196,7 +201,7 @@ class SelfServiceController extends ActionController
|
|||||||
$key = $this->params->getRequired('key');
|
$key = $this->params->getRequired('key');
|
||||||
$host = IcingaHost::loadWithApiKey($key, $db);
|
$host = IcingaHost::loadWithApiKey($key, $db);
|
||||||
|
|
||||||
$settings = new Settings($db);
|
$settings = $this->getSettings();
|
||||||
$params = [
|
$params = [
|
||||||
'fetch_agent_name' => $settings->get('self-service/agent_name') === 'hostname',
|
'fetch_agent_name' => $settings->get('self-service/agent_name') === 'hostname',
|
||||||
'fetch_agent_fqdn' => $settings->get('self-service/agent_name') === 'fqdn',
|
'fetch_agent_fqdn' => $settings->get('self-service/agent_name') === 'fqdn',
|
||||||
@ -210,7 +215,7 @@ class SelfServiceController extends ActionController
|
|||||||
$params['allow_updates'] = $settings->get('self-service/allow_updates') === 'y';
|
$params['allow_updates'] = $settings->get('self-service/allow_updates') === 'y';
|
||||||
$params['agent_listen_port'] = $host->getAgentListenPort();
|
$params['agent_listen_port'] = $host->getAgentListenPort();
|
||||||
if ($hashes = $settings->get('self-service/installer_hashes')) {
|
if ($hashes = $settings->get('self-service/installer_hashes')) {
|
||||||
$params['installer_hashes'] = json_decode($hashes);
|
$params['installer_hashes'] = $hashes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($settings->get('self-service/install_nsclient') === 'y') {
|
if ($settings->get('self-service/install_nsclient') === 'y') {
|
||||||
@ -245,6 +250,7 @@ class SelfServiceController extends ActionController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$db = $this->db();
|
$db = $this->db();
|
||||||
|
$settings = $this->getSettings();
|
||||||
$name = $host->getObjectName();
|
$name = $host->getObjectName();
|
||||||
if ($host->getSingleResolvedProperty('has_agent') !== 'y') {
|
if ($host->getSingleResolvedProperty('has_agent') !== 'y') {
|
||||||
$this->sendPowerShellError(sprintf(
|
$this->sendPowerShellError(sprintf(
|
||||||
@ -266,13 +272,7 @@ class SelfServiceController extends ActionController
|
|||||||
$params['agent_add_firewall_rule'] = $host
|
$params['agent_add_firewall_rule'] = $host
|
||||||
->getSingleResolvedProperty('master_should_connect') === 'y';
|
->getSingleResolvedProperty('master_should_connect') === 'y';
|
||||||
|
|
||||||
$zdb = $db->getDbAdapter();
|
$params['global_zones'] = $settings->get('self-service/global_zones');
|
||||||
$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);
|
$zone = IcingaZone::load($zoneName, $db);
|
||||||
$master = $db->getDeploymentEndpoint();
|
$master = $db->getDeploymentEndpoint();
|
||||||
@ -301,4 +301,13 @@ class SelfServiceController extends ActionController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getSettings()
|
||||||
|
{
|
||||||
|
if ($this->settings === null) {
|
||||||
|
$this->settings = new Settings($this->db());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->settings;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,11 +133,6 @@ class SelfServiceSettingsForm extends DirectorForm
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
$hashes = $settings->getStoredOrDefaultValue('self-service/installer_hashes');
|
$hashes = $settings->getStoredOrDefaultValue('self-service/installer_hashes');
|
||||||
if ($hashes) {
|
|
||||||
$hashes = json_decode($hashes);
|
|
||||||
} else {
|
|
||||||
$hashes = null;
|
|
||||||
}
|
|
||||||
$this->addElement('extensibleSet', 'installer_hashes', [
|
$this->addElement('extensibleSet', 'installer_hashes', [
|
||||||
'label' => $this->translate('Installer Hashes'),
|
'label' => $this->translate('Installer Hashes'),
|
||||||
'description' => $this->translate(
|
'description' => $this->translate(
|
||||||
@ -152,8 +147,8 @@ class SelfServiceSettingsForm extends DirectorForm
|
|||||||
'value' => $hashes,
|
'value' => $hashes,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->addElement('extensibleSet', 'installer_hashes', [
|
$this->addElement('extensibleSet', 'global_zones', [
|
||||||
'label' => $this->translate('Installer Hashes'),
|
'label' => $this->translate('Global Zones'),
|
||||||
'description' => $this->translate(
|
'description' => $this->translate(
|
||||||
'To ensure downloaded packages are build by the Icinga Team'
|
'To ensure downloaded packages are build by the Icinga Team'
|
||||||
. ' and not compromised by third parties, you will be able'
|
. ' and not compromised by third parties, you will be able'
|
||||||
@ -163,7 +158,8 @@ class SelfServiceSettingsForm extends DirectorForm
|
|||||||
. ' the downloaded MSI package is not matching one of the'
|
. ' the downloaded MSI package is not matching one of the'
|
||||||
. ' provided hashes of this setting'
|
. ' provided hashes of this setting'
|
||||||
),
|
),
|
||||||
'value' => $hashes,
|
'multiOptions' => $this->enumGlobalZones(),
|
||||||
|
'value' => $settings->getStoredOrDefaultValue('self-service/global_zones'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->addElement('text', 'icinga_service_user', [
|
$this->addElement('text', 'icinga_service_user', [
|
||||||
@ -238,6 +234,19 @@ class SelfServiceSettingsForm extends DirectorForm
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function enumGlobalZones()
|
||||||
|
{
|
||||||
|
$db = $this->getDb()->getDbAdapter();
|
||||||
|
$zones = $db->fetchCol(
|
||||||
|
$db->select()->from('icinga_zone', 'object_name')
|
||||||
|
->where('disabled = ?', 'n')
|
||||||
|
->where('is_global = ?', 'y')
|
||||||
|
->order('object_name')
|
||||||
|
);
|
||||||
|
|
||||||
|
return array_combine($zones, $zones);
|
||||||
|
}
|
||||||
|
|
||||||
public function setSettings(Settings $settings)
|
public function setSettings(Settings $settings)
|
||||||
{
|
{
|
||||||
$this->settings = $settings;
|
$this->settings = $settings;
|
||||||
@ -252,9 +261,6 @@ class SelfServiceSettingsForm extends DirectorForm
|
|||||||
$value = null;
|
$value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($value)) {
|
|
||||||
$value = json_encode($value);
|
|
||||||
}
|
|
||||||
$this->settings->set("self-service/$key", $value);
|
$this->settings->set("self-service/$key", $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user