Sync: do not touch 'disabled' on merge unless...
...it has been defined as a Sync Property fixes #1223
This commit is contained in:
parent
c9c59b3f03
commit
8f7e9e9ecd
|
@ -10,10 +10,14 @@ before switching to a new version.
|
|||
* You can find issues and feature requests related to this release on our
|
||||
[roadmap](https://github.com/Icinga/icingaweb2-module-director/milestone/12?closed=1)
|
||||
|
||||
### Automation
|
||||
* FIX: A Sync Rule with `merge` policy used to re-enable manually disabled objects,
|
||||
even when no Sync Property `disabled` has been defined
|
||||
|
||||
### Large environments
|
||||
* Director tries to raise it's memory limit for certain memory-intensive tasks.
|
||||
When granted more (but not infinite) memory however this had the effect that
|
||||
he self-restricted himself to a lower limit. This has now been fixed.
|
||||
* FIX: Director tries to raise it's memory limit for certain memory-intensive
|
||||
tasks. When granted more (but not infinite) memory however this had the effect
|
||||
that he self-restricted himself to a lower limit.
|
||||
|
||||
1.4.0
|
||||
-----
|
||||
|
|
|
@ -458,6 +458,16 @@ abstract class DbObject
|
|||
return $props;
|
||||
}
|
||||
|
||||
/**
|
||||
* List all properties that changed since object creation
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function listModifiedProperties()
|
||||
{
|
||||
return array_keys($this->modifiedProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this object has been modified
|
||||
*
|
||||
|
@ -668,6 +678,16 @@ abstract class DbObject
|
|||
return null;
|
||||
}
|
||||
|
||||
public function resetProperty($key)
|
||||
{
|
||||
$this->set($key, $this->getOriginalProperty($key));
|
||||
if ($this->listModifiedProperties() === [$key]) {
|
||||
$this->hasBeenModified = false;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function hasBeenLoadedFromDb()
|
||||
{
|
||||
return $this->loadedFromDb;
|
||||
|
|
|
@ -14,6 +14,7 @@ use Icinga\Module\Director\Objects\IcingaHostGroup;
|
|||
use Icinga\Module\Director\Objects\IcingaObject;
|
||||
use Icinga\Module\Director\Objects\ImportSource;
|
||||
use Icinga\Module\Director\Objects\IcingaService;
|
||||
use Icinga\Module\Director\Objects\SyncProperty;
|
||||
use Icinga\Module\Director\Objects\SyncRule;
|
||||
use Icinga\Module\Director\Objects\SyncRun;
|
||||
use Icinga\Module\Director\Util;
|
||||
|
@ -72,6 +73,7 @@ class Sync
|
|||
|
||||
protected $errors = array();
|
||||
|
||||
/** @var SyncProperty[] */
|
||||
protected $syncProperties;
|
||||
|
||||
protected $replaceVars = false;
|
||||
|
@ -585,9 +587,16 @@ class Sync
|
|||
// TODO: directly work on existing objects, remember imported keys, then purge
|
||||
$newObjects = $this->prepareNewObjects();
|
||||
|
||||
$hasDisabled = false;
|
||||
foreach ($this->syncProperties as $property) {
|
||||
if ($property->get('destination_field') === 'disabled') {
|
||||
$hasDisabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($newObjects as $key => $object) {
|
||||
if (array_key_exists($key, $this->objects)) {
|
||||
switch ($this->rule->update_policy) {
|
||||
switch ($this->rule->get('update_policy')) {
|
||||
case 'override':
|
||||
$this->objects[$key]->replaceWith($object);
|
||||
break;
|
||||
|
@ -596,6 +605,9 @@ class Sync
|
|||
// TODO: re-evaluate merge settings. vars.x instead of
|
||||
// just "vars" might suffice.
|
||||
$this->objects[$key]->merge($object, $this->replaceVars);
|
||||
if (! $hasDisabled) {
|
||||
$this->objects[$key]->resetProperty('disabled');
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue