mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2026-02-18 18:30:00 -05:00
Ensure that backend states are applied when applying ProcessChanges
This commit is contained in:
parent
2111103957
commit
ec14bdff0d
5 changed files with 57 additions and 7 deletions
|
|
@ -94,12 +94,14 @@ class ProcessController extends Controller
|
|||
$bp = $this->loadModifiedBpConfig();
|
||||
$node = $this->getNode($bp);
|
||||
|
||||
if (Module::exists('icingadb') &&
|
||||
(! $bp->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend())
|
||||
) {
|
||||
IcingaDbState::apply($bp);
|
||||
} else {
|
||||
MonitoringState::apply($bp);
|
||||
if (! $bp->statesApplied()) {
|
||||
if (Module::exists('icingadb') &&
|
||||
(! $bp->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend())
|
||||
) {
|
||||
IcingaDbState::apply($bp);
|
||||
} else {
|
||||
MonitoringState::apply($bp);
|
||||
}
|
||||
}
|
||||
|
||||
$this->handleSimulations($bp);
|
||||
|
|
|
|||
|
|
@ -133,6 +133,9 @@ class BpConfig
|
|||
/** @var bool Whether the config is faulty */
|
||||
protected $isFaulty = false;
|
||||
|
||||
/** @var bool Whether the backend states are applied */
|
||||
protected bool $statesApplied = false;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
|
@ -151,6 +154,30 @@ class BpConfig
|
|||
return $this->metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get whether the backend states are applied
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function statesApplied(): bool
|
||||
{
|
||||
return $this->statesApplied;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether the backend states are applied
|
||||
*
|
||||
* @param bool $statesApplied
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setStatesApplied(bool $statesApplied = true): static
|
||||
{
|
||||
$this->statesApplied = $statesApplied;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set metadata
|
||||
*
|
||||
|
|
|
|||
|
|
@ -146,6 +146,8 @@ class IcingaDbState
|
|||
Benchmark::measure('Retrieved states for ' . count($hostIds) . ' hosts in ' . $config->getName());
|
||||
}
|
||||
|
||||
$config->setStatesApplied();
|
||||
|
||||
Benchmark::measure('Got states for business process ' . $config->getName());
|
||||
|
||||
return $this;
|
||||
|
|
|
|||
|
|
@ -107,6 +107,7 @@ class MonitoringState
|
|||
}
|
||||
}
|
||||
|
||||
$config->setStatesApplied();
|
||||
// TODO: Union, single query?
|
||||
Benchmark::measure('Got states for business process ' . $config->getName());
|
||||
|
||||
|
|
|
|||
|
|
@ -3,8 +3,12 @@
|
|||
namespace Icinga\Module\Businessprocess\Web;
|
||||
|
||||
use Icinga\Application\Icinga;
|
||||
use Icinga\Application\Modules\Module;
|
||||
use Icinga\Module\Businessprocess\BpConfig;
|
||||
use Icinga\Module\Businessprocess\Modification\ProcessChanges;
|
||||
use Icinga\Module\Businessprocess\ProvidedHook\Icingadb\IcingadbSupport;
|
||||
use Icinga\Module\Businessprocess\State\IcingaDbState;
|
||||
use Icinga\Module\Businessprocess\State\MonitoringState;
|
||||
use Icinga\Module\Businessprocess\Storage\LegacyStorage;
|
||||
use Icinga\Module\Businessprocess\Storage\Storage;
|
||||
use Icinga\Module\Businessprocess\Web\Component\ActionBar;
|
||||
|
|
@ -196,7 +200,21 @@ class Controller extends CompatController
|
|||
$changes->clear();
|
||||
$this->redirectNow($this->url()->without('dismissChanges')->without('unlocked'));
|
||||
}
|
||||
$bp->applyChanges($changes);
|
||||
|
||||
if (! $changes->isEmpty()) {
|
||||
if (! $bp->statesApplied()) {
|
||||
if (Module::exists('icingadb') &&
|
||||
(! $bp->hasBackendName() && IcingadbSupport::useIcingaDbAsBackend())
|
||||
) {
|
||||
IcingaDbState::apply($bp);
|
||||
} else {
|
||||
MonitoringState::apply($bp);
|
||||
}
|
||||
}
|
||||
|
||||
$bp->applyChanges($changes);
|
||||
}
|
||||
|
||||
return $bp;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue