mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-09-26 11:19:16 +02:00
Sync: finish combined key support
Services on hosts should be fine right now
This commit is contained in:
parent
ca76f30aa0
commit
e455bbf37a
@ -4,6 +4,7 @@ namespace Icinga\Module\Director\Import;
|
|||||||
|
|
||||||
use Icinga\Module\Director\Objects\IcingaObject;
|
use Icinga\Module\Director\Objects\IcingaObject;
|
||||||
use Icinga\Module\Director\Objects\ImportSource;
|
use Icinga\Module\Director\Objects\ImportSource;
|
||||||
|
use Icinga\Module\Director\Objects\IcingaService;
|
||||||
use Icinga\Module\Director\Objects\SyncRule;
|
use Icinga\Module\Director\Objects\SyncRule;
|
||||||
use Icinga\Module\Director\Objects\SyncRun;
|
use Icinga\Module\Director\Objects\SyncRun;
|
||||||
use Icinga\Module\Director\Util;
|
use Icinga\Module\Director\Util;
|
||||||
@ -443,11 +444,41 @@ class Sync
|
|||||||
|
|
||||||
protected function loadExistingObjects()
|
protected function loadExistingObjects()
|
||||||
{
|
{
|
||||||
|
$this->objects = array();
|
||||||
|
|
||||||
// TODO: Make object_type (template, object...) and object_name mandatory?
|
// TODO: Make object_type (template, object...) and object_name mandatory?
|
||||||
$this->objects = IcingaObject::loadAllByType(
|
if ($this->hasCombinedKey()) {
|
||||||
$this->rule->object_type,
|
|
||||||
$this->db
|
foreach (IcingaObject::loadAllByType(
|
||||||
);
|
$this->rule->object_type,
|
||||||
|
$this->db
|
||||||
|
) as $object) {
|
||||||
|
|
||||||
|
if ($object instanceof IcingaService) {
|
||||||
|
if (! $object->host_id) continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$key = $this->fillVariables(
|
||||||
|
$this->destinationKeyPattern,
|
||||||
|
$object
|
||||||
|
);
|
||||||
|
|
||||||
|
if (array_key_exists($key, $this->objects)) {
|
||||||
|
throw new IcingaException(
|
||||||
|
'Combined destination key "%s" is not unique, got "%s" twice',
|
||||||
|
$this->destinationKeyPattern,
|
||||||
|
$key
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->objects[$key] = $object;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$this->objects = IcingaObject::loadAllByType(
|
||||||
|
$this->rule->object_type,
|
||||||
|
$this->db
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: should be obsoleted by a better "loadFiltered" method
|
// TODO: should be obsoleted by a better "loadFiltered" method
|
||||||
if ($this->rule->object_type === 'datalistEntry') {
|
if ($this->rule->object_type === 'datalistEntry') {
|
||||||
@ -553,8 +584,8 @@ class Sync
|
|||||||
->fetchSyncProperties()
|
->fetchSyncProperties()
|
||||||
->prepareRelatedImportSources()
|
->prepareRelatedImportSources()
|
||||||
->prepareSourceColumns()
|
->prepareSourceColumns()
|
||||||
|
->loadExistingObjects()
|
||||||
->fetchImportedData()
|
->fetchImportedData()
|
||||||
->loadExistingObjects();
|
|
||||||
|
|
||||||
// TODO: directly work on existing objects, remember imported keys, then purge
|
// TODO: directly work on existing objects, remember imported keys, then purge
|
||||||
$newObjects = $this->prepareNewObjects();
|
$newObjects = $this->prepareNewObjects();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user