kickstart: add new route /kickstart allowing one...
...to re-run the kickstart wizard fixes #13014
This commit is contained in:
parent
cbf1a30a26
commit
55e0ebd02d
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Director\Controllers;
|
||||
|
||||
use Exception;
|
||||
use Icinga\Module\Director\Db\Migrations;
|
||||
|
||||
class KickstartController extends DashboardController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->singleTab($this->view->title = $this->translate('Kickstart'));
|
||||
$this->view->form = $this
|
||||
->loadForm('kickstart')
|
||||
->setEndpoint($this->db()->getDeploymentEndpoint())
|
||||
->handleRequest();
|
||||
}
|
||||
}
|
|
@ -7,18 +7,22 @@ use Icinga\Application\Config;
|
|||
use Icinga\Data\ResourceFactory;
|
||||
use Icinga\Module\Director\Db;
|
||||
use Icinga\Module\Director\Db\Migrations;
|
||||
use Icinga\Module\Director\Objects\IcingaEndpoint;
|
||||
use Icinga\Module\Director\KickstartHelper;
|
||||
use Icinga\Module\Director\Web\Form\QuickForm;
|
||||
|
||||
class KickstartForm extends QuickForm
|
||||
{
|
||||
protected $config;
|
||||
private $config;
|
||||
|
||||
protected $storeConfigLabel;
|
||||
private $storeConfigLabel;
|
||||
|
||||
protected $createDbLabel;
|
||||
private $createDbLabel;
|
||||
|
||||
protected $migrateDbLabel;
|
||||
private $migrateDbLabel;
|
||||
|
||||
/** @var IcingaEndpoint */
|
||||
private $endpoint;
|
||||
|
||||
public function setup()
|
||||
{
|
||||
|
@ -56,7 +60,7 @@ class KickstartForm extends QuickForm
|
|||
return;
|
||||
}
|
||||
|
||||
if ($this->getDb()->hasDeploymentEndpoint()) {
|
||||
if (! $this->endpoint && $this->getDb()->hasDeploymentEndpoint()) {
|
||||
$hint = sprintf($this->translate(
|
||||
'Your database looks good, you are ready to %s'
|
||||
), $this->getView()->qlink(
|
||||
|
@ -136,6 +140,24 @@ class KickstartForm extends QuickForm
|
|||
'required' => true,
|
||||
));
|
||||
|
||||
if ($ep = $this->endpoint) {
|
||||
$user = $ep->getApiUser();
|
||||
$this->setDefaults(array(
|
||||
'endpoint' => $ep->object_name,
|
||||
'host' => $ep->host,
|
||||
'port' => $ep->port,
|
||||
'username' => $user->object_name,
|
||||
'password' => $user->password,
|
||||
));
|
||||
|
||||
if (! empty($user->password)) {
|
||||
$this->getElement('password')->setAttrib(
|
||||
'placeholder',
|
||||
'(use stored password)'
|
||||
)->setRequired(false);
|
||||
}
|
||||
}
|
||||
|
||||
$this->addKickstartDisplayGroup();
|
||||
$this->setSubmitLabel($this->translate('Run import'));
|
||||
}
|
||||
|
@ -288,6 +310,12 @@ class KickstartForm extends QuickForm
|
|||
}
|
||||
}
|
||||
|
||||
public function setEndpoint(IcingaEndpoint $endpoint)
|
||||
{
|
||||
$this->endpoint = $endpoint;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function onSuccess()
|
||||
{
|
||||
try {
|
||||
|
@ -306,6 +334,10 @@ class KickstartForm extends QuickForm
|
|||
}
|
||||
|
||||
$values = $this->getValues();
|
||||
if ($this->endpoint && empty($values['password'])) {
|
||||
$values['password'] = $this->endpoint->getApiUser()->password;
|
||||
}
|
||||
|
||||
$kickstart = new KickstartHelper($this->getDb());
|
||||
unset($values['resource']);
|
||||
$kickstart->setConfig($values)->run();
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<div class="controls">
|
||||
<?= $this->tabs ?>
|
||||
<h1><?= $this->escape($this->title) ?><?php
|
||||
if ($this->subtitle) {
|
||||
echo ' <small>' . $this->escape($this->subtitle) . '</small>';
|
||||
}
|
||||
?></h1>
|
||||
<span class="action-links">
|
||||
<?= $this->actionLinks ?>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="content">
|
||||
<?= $this->form ?>
|
||||
</div>
|
Loading…
Reference in New Issue