mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02:00
SelfService: add Icinga for Windows support...
...to the Agent tab fixes #2147
This commit is contained in:
parent
9de84c3a72
commit
62c4c6f44b
@ -146,7 +146,23 @@ class AgentWizard
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderTokenBasedWindowsInstaller($token, $withModule = false)
|
public function renderIcinga4WindowsWizardCommand($token)
|
||||||
|
{
|
||||||
|
$script = "Use-Icinga;\n"
|
||||||
|
. 'Start-IcingaAgentInstallWizard `' . "\n "
|
||||||
|
. $this->renderPowershellParameters([
|
||||||
|
'DirectorUrl' => $this->getDirectorUrl(),
|
||||||
|
'SelfServiceAPIKey' => $token,
|
||||||
|
'UseDirectorSelfService' => 1,
|
||||||
|
'OverrideDirectorVars' => 0,
|
||||||
|
'Reconfigure',
|
||||||
|
'RunInstaller'
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $script;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function renderPowershellModuleInstaller($token, $withModule = false)
|
||||||
{
|
{
|
||||||
if ($withModule) {
|
if ($withModule) {
|
||||||
$script = $this->loadPowershellModule() . "\n\n";
|
$script = $this->loadPowershellModule() . "\n\n";
|
||||||
@ -217,7 +233,9 @@ class AgentWizard
|
|||||||
$vals[] = $this->renderPowershellString($val);
|
$vals[] = $this->renderPowershellString($val);
|
||||||
}
|
}
|
||||||
$ret .= implode(', ', $vals);
|
$ret .= implode(', ', $vals);
|
||||||
} elseif ($value !== null) {
|
} elseif (is_int($value)) {
|
||||||
|
$ret .= $value;
|
||||||
|
} else {
|
||||||
$ret .= $this->renderPowershellString($value);
|
$ret .= $this->renderPowershellString($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ use Icinga\Exception\NotFoundError;
|
|||||||
use Icinga\Module\Director\IcingaConfig\AgentWizard;
|
use Icinga\Module\Director\IcingaConfig\AgentWizard;
|
||||||
use Icinga\Module\Director\Objects\IcingaHost;
|
use Icinga\Module\Director\Objects\IcingaHost;
|
||||||
use Icinga\Module\Director\Util;
|
use Icinga\Module\Director\Util;
|
||||||
|
use Icinga\Module\Director\Web\Widget\Documentation;
|
||||||
use ipl\Html\Html;
|
use ipl\Html\Html;
|
||||||
use gipfl\IcingaWeb2\Link;
|
use gipfl\IcingaWeb2\Link;
|
||||||
use gipfl\Translation\TranslationHelper;
|
use gipfl\Translation\TranslationHelper;
|
||||||
@ -100,24 +101,43 @@ class SelfService
|
|||||||
]
|
]
|
||||||
));
|
));
|
||||||
|
|
||||||
if ($this->hasDocsModuleLoaded()) {
|
$actions->add(Documentation::link(
|
||||||
$actions->add(Link::create(
|
$this->translate('Documentation'),
|
||||||
$this->translate('Documentation'),
|
'director',
|
||||||
'doc/module/director/chapter/Self-Service-API',
|
'74-Self-Service-API',
|
||||||
null,
|
$this->translate('Self Service API')
|
||||||
['class' => 'icon-book']
|
));
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($hasKey) {
|
if ($hasKey) {
|
||||||
$wizard = new AgentWizard($host);
|
$wizard = new AgentWizard($host);
|
||||||
|
|
||||||
$c->add([
|
$c->add([
|
||||||
Html::tag('p', null, [$this->translate('Api Key:'), ' ', Html::tag('strong', null, $key)]),
|
Html::tag('p', null, [$this->translate('Api Key:'), ' ', Html::tag('strong', null, $key)]),
|
||||||
|
Html::tag('h2', $this->translate('Icinga for Windows')),
|
||||||
|
Html::tag('p', Html::sprintf(
|
||||||
|
$this->translate('In case you\'re using %s, please run this Script:'),
|
||||||
|
Html::tag('a', [
|
||||||
|
'href' => 'https://icinga.com/docs/windows/latest/',
|
||||||
|
'target' => '_blank',
|
||||||
|
], $this->translate('Icinga for Windows'))
|
||||||
|
)),
|
||||||
Html::tag(
|
Html::tag(
|
||||||
'pre',
|
'pre',
|
||||||
['class' => 'logfile'],
|
['class' => 'logfile'],
|
||||||
$wizard->renderTokenBasedWindowsInstaller($key)
|
$wizard->renderIcinga4WindowsWizardCommand($key)
|
||||||
|
),
|
||||||
|
Html::tag('h3', $this->translate('Icinga 2 Powershell Module')),
|
||||||
|
Html::tag('p', Html::sprintf(
|
||||||
|
$this->translate('In case you\'re using the legacy %s, please run:'),
|
||||||
|
Html::tag('a', [
|
||||||
|
'href' => 'https://github.com/Icinga/icinga2-powershell-module',
|
||||||
|
'target' => '_blank',
|
||||||
|
], $this->translate('Icinga 2 Powershell Module'))
|
||||||
|
)),
|
||||||
|
Html::tag(
|
||||||
|
'pre',
|
||||||
|
['class' => 'logfile'],
|
||||||
|
$wizard->renderPowershellModuleInstaller($key)
|
||||||
),
|
),
|
||||||
Html::tag('h2', null, $this->translate('Generate a new key')),
|
Html::tag('h2', null, $this->translate('Generate a new key')),
|
||||||
Hint::warning($this->translate(
|
Hint::warning($this->translate(
|
||||||
@ -136,6 +156,9 @@ class SelfService
|
|||||||
Html::tag('p', null, $this->translate(
|
Html::tag('p', null, $this->translate(
|
||||||
'You can stop sharing a Template at any time. This will'
|
'You can stop sharing a Template at any time. This will'
|
||||||
. ' immediately invalidate the former key.'
|
. ' immediately invalidate the former key.'
|
||||||
|
) . ' ' . $this->translate(
|
||||||
|
'Generated Host keys will continue to work, but you\'ll no'
|
||||||
|
. ' longer be able to register new Hosts with this key'
|
||||||
)),
|
)),
|
||||||
IcingaForgetApiKeyForm::load()->setHost($host)->handleRequest()
|
IcingaForgetApiKeyForm::load()->setHost($host)->handleRequest()
|
||||||
]);
|
]);
|
||||||
@ -169,7 +192,7 @@ class SelfService
|
|||||||
Html::tag(
|
Html::tag(
|
||||||
'pre',
|
'pre',
|
||||||
['class' => 'logfile'],
|
['class' => 'logfile'],
|
||||||
$wizard->renderTokenBasedWindowsInstaller($key)
|
$wizard->renderIcinga4WindowsWizardCommand($key)
|
||||||
)
|
)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user