mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-28 16:24:05 +02:00
Kickstart: deal with multiple DBs
This commit is contained in:
parent
8cec78a7c3
commit
fa70ecde0e
@ -22,7 +22,6 @@ class IndexController extends DashboardController
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$this->showKickstartForm();
|
$this->showKickstartForm();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($migrations->hasPendingMigrations()) {
|
if ($migrations->hasPendingMigrations()) {
|
||||||
@ -45,7 +44,11 @@ class IndexController extends DashboardController
|
|||||||
$this->addSingleTab($this->translate('Kickstart'));
|
$this->addSingleTab($this->translate('Kickstart'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->content()->prepend(KickstartForm::load()->handleRequest());
|
$form = KickstartForm::load();
|
||||||
|
if ($name = $this->getPreferredDbResourceName()) {
|
||||||
|
$form->setDbResourceName($name);
|
||||||
|
}
|
||||||
|
$this->content()->prepend($form->handleRequest());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function hasDeploymentEndpoint()
|
protected function hasDeploymentEndpoint()
|
||||||
|
@ -26,8 +26,9 @@ class KickstartForm extends DirectorForm
|
|||||||
/** @var IcingaEndpoint */
|
/** @var IcingaEndpoint */
|
||||||
private $endpoint;
|
private $endpoint;
|
||||||
|
|
||||||
|
private $dbResourceName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \Icinga\Exception\IcingaException
|
|
||||||
* @throws \Zend_Form_Exception
|
* @throws \Zend_Form_Exception
|
||||||
*/
|
*/
|
||||||
public function setup()
|
public function setup()
|
||||||
@ -36,12 +37,14 @@ class KickstartForm extends DirectorForm
|
|||||||
$this->createDbLabel = $this->translate('Create database schema');
|
$this->createDbLabel = $this->translate('Create database schema');
|
||||||
$this->migrateDbLabel = $this->translate('Apply schema migrations');
|
$this->migrateDbLabel = $this->translate('Apply schema migrations');
|
||||||
|
|
||||||
$this->addResourceConfigElements();
|
if ($this->dbResourceName === null) {
|
||||||
$this->addResourceDisplayGroup();
|
$this->addResourceConfigElements();
|
||||||
|
$this->addResourceDisplayGroup();
|
||||||
|
|
||||||
if (!$this->config()->get('db', 'resource')
|
if (!$this->config()->get('db', 'resource')
|
||||||
|| ($this->config()->get('db', 'resource') !== $this->getResourceName())) {
|
|| ($this->config()->get('db', 'resource') !== $this->getResourceName())) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->migrations()->hasSchema()) {
|
if (!$this->migrations()->hasSchema()) {
|
||||||
@ -266,6 +269,10 @@ class KickstartForm extends DirectorForm
|
|||||||
*/
|
*/
|
||||||
protected function addResourceDisplayGroup()
|
protected function addResourceDisplayGroup()
|
||||||
{
|
{
|
||||||
|
if ($this->dbResourceName !== null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$elements = array(
|
$elements = array(
|
||||||
'HINT_no_resource',
|
'HINT_no_resource',
|
||||||
'resource',
|
'resource',
|
||||||
@ -353,7 +360,6 @@ class KickstartForm extends DirectorForm
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws \Icinga\Exception\IcingaException
|
|
||||||
* @throws \Icinga\Exception\ProgrammingError
|
* @throws \Icinga\Exception\ProgrammingError
|
||||||
* @throws \Zend_Form_Exception
|
* @throws \Zend_Form_Exception
|
||||||
*/
|
*/
|
||||||
@ -385,8 +391,19 @@ class KickstartForm extends DirectorForm
|
|||||||
parent::onSuccess();
|
parent::onSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setDbResourceName($name)
|
||||||
|
{
|
||||||
|
$this->dbResourceName = $name;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
protected function getResourceName()
|
protected function getResourceName()
|
||||||
{
|
{
|
||||||
|
if ($this->dbResourceName !== null) {
|
||||||
|
return $this->dbResourceName;
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->hasBeenSent()) {
|
if ($this->hasBeenSent()) {
|
||||||
$resource = $this->getSentValue('resource');
|
$resource = $this->getSentValue('resource');
|
||||||
$resources = $this->enumResources();
|
$resources = $this->enumResources();
|
||||||
@ -412,7 +429,6 @@ class KickstartForm extends DirectorForm
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Migrations
|
* @return Migrations
|
||||||
* @throws \Icinga\Exception\IcingaException
|
|
||||||
*/
|
*/
|
||||||
protected function migrations()
|
protected function migrations()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user