parent
41f428e86b
commit
a8d25b70ee
|
@ -74,9 +74,23 @@ class SyncRuleForm extends DirectorObjectForm
|
||||||
. ' longer exist at your import source.'
|
. ' longer exist at your import source.'
|
||||||
),
|
),
|
||||||
'required' => true,
|
'required' => true,
|
||||||
|
'class' => 'autosubmit',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if ($this->getSentOrObjectValue('purge_existing') === 'y') {
|
||||||
|
$this->addElement('select', 'purge_action', [
|
||||||
|
'label' => $this->translate('Purge Action'),
|
||||||
|
'description' => $this->translate(
|
||||||
|
'Whether to delete or to disable objects subject to purge'
|
||||||
|
),
|
||||||
|
'multiOptions' => $this->optionalEnum([
|
||||||
|
'delete' => $this->translate('Delete'),
|
||||||
|
'disable' => $this->translate('Disable'),
|
||||||
|
]),
|
||||||
|
'required' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
$this->addElement('text', 'filter_expression', [
|
$this->addElement('text', 'filter_expression', [
|
||||||
'label' => $this->translate('Filter Expression'),
|
'label' => $this->translate('Filter Expression'),
|
||||||
'description' => sprintf(
|
'description' => sprintf(
|
||||||
|
|
|
@ -14,6 +14,9 @@ next (will be 1.8.1)
|
||||||
### User Interface
|
### User Interface
|
||||||
* FIX: don't fail when showing a Host overriding multiple inherited groups (#2253)
|
* FIX: don't fail when showing a Host overriding multiple inherited groups (#2253)
|
||||||
|
|
||||||
|
### Import and Sync
|
||||||
|
* FEATURE: introduce 'disable' as your purge action on Sync (#2285)
|
||||||
|
|
||||||
### Automation, User Interface
|
### Automation, User Interface
|
||||||
* FIX: error message wording on failing related (or parent) object ref (#2224)
|
* FIX: error message wording on failing related (or parent) object ref (#2224)
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ use Icinga\Module\Director\Objects\SyncRun;
|
||||||
use Icinga\Exception\IcingaException;
|
use Icinga\Exception\IcingaException;
|
||||||
use Icinga\Module\Director\Repository\IcingaTemplateRepository;
|
use Icinga\Module\Director\Repository\IcingaTemplateRepository;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
|
use RuntimeException;
|
||||||
|
|
||||||
class Sync
|
class Sync
|
||||||
{
|
{
|
||||||
|
@ -633,6 +634,7 @@ class Sync
|
||||||
|
|
||||||
Benchmark::measure('Modified objects are ready, applying purge strategy');
|
Benchmark::measure('Modified objects are ready, applying purge strategy');
|
||||||
$noAction = [];
|
$noAction = [];
|
||||||
|
$purgeAction = $this->rule->get('purge_action');
|
||||||
foreach ($this->rule->purgeStrategy()->listObjectsToPurge() as $key) {
|
foreach ($this->rule->purgeStrategy()->listObjectsToPurge() as $key) {
|
||||||
if (array_key_exists($key, $newObjects)) {
|
if (array_key_exists($key, $newObjects)) {
|
||||||
// Object has been touched, do not delete
|
// Object has been touched, do not delete
|
||||||
|
@ -642,7 +644,18 @@ class Sync
|
||||||
if (array_key_exists($key, $this->objects)) {
|
if (array_key_exists($key, $this->objects)) {
|
||||||
$object = $this->objects[$key];
|
$object = $this->objects[$key];
|
||||||
if (! $object->hasBeenModified()) {
|
if (! $object->hasBeenModified()) {
|
||||||
$object->markForRemoval();
|
switch ($purgeAction) {
|
||||||
|
case 'delete':
|
||||||
|
$object->markForRemoval();
|
||||||
|
break;
|
||||||
|
case 'disable':
|
||||||
|
$object->set('disabled', 'y');
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new RuntimeException(
|
||||||
|
"Unsupported purge action: '$purgeAction'"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ class SyncRule extends DbObject implements ExportInterface
|
||||||
'object_type' => null,
|
'object_type' => null,
|
||||||
'update_policy' => null,
|
'update_policy' => null,
|
||||||
'purge_existing' => null,
|
'purge_existing' => null,
|
||||||
|
'purge_action' => null,
|
||||||
'filter_expression' => null,
|
'filter_expression' => null,
|
||||||
'sync_state' => 'unknown',
|
'sync_state' => 'unknown',
|
||||||
'last_error_message' => null,
|
'last_error_message' => null,
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
ALTER TABLE sync_rule
|
||||||
|
ADD COLUMN purge_action ENUM('delete', 'disable') NULL DEFAULT NULL AFTER purge_existing;
|
||||||
|
|
||||||
|
UPDATE sync_rule SET purge_action = 'delete';
|
||||||
|
|
||||||
|
ALTER TABLE sync_rule
|
||||||
|
MODIFY COLUMN purge_action ENUM('delete', 'disable') DEFAULT NULL;
|
||||||
|
|
||||||
|
INSERT INTO director_schema_migration
|
||||||
|
(schema_version, migration_time)
|
||||||
|
VALUES (172, NOW());
|
|
@ -1526,6 +1526,7 @@ CREATE TABLE sync_rule (
|
||||||
) NOT NULL,
|
) NOT NULL,
|
||||||
update_policy ENUM('merge', 'override', 'ignore', 'update-only') NOT NULL,
|
update_policy ENUM('merge', 'override', 'ignore', 'update-only') NOT NULL,
|
||||||
purge_existing ENUM('y', 'n') NOT NULL DEFAULT 'n',
|
purge_existing ENUM('y', 'n') NOT NULL DEFAULT 'n',
|
||||||
|
purge_action ENUM('delete', 'disable') NOT NULL,
|
||||||
filter_expression TEXT DEFAULT NULL,
|
filter_expression TEXT DEFAULT NULL,
|
||||||
sync_state ENUM(
|
sync_state ENUM(
|
||||||
'unknown',
|
'unknown',
|
||||||
|
@ -1883,4 +1884,4 @@ CREATE TABLE icinga_scheduled_downtime_range (
|
||||||
|
|
||||||
INSERT INTO director_schema_migration
|
INSERT INTO director_schema_migration
|
||||||
(schema_version, migration_time)
|
(schema_version, migration_time)
|
||||||
VALUES (171, NOW());
|
VALUES (172, NOW());
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
CREATE TYPE enum_sync_rule_purge_action AS ENUM('delete', 'disable');
|
||||||
|
|
||||||
|
ALTER TABLE sync_rule
|
||||||
|
ADD COLUMN purge_action enum_sync_rule_purge_action NULL DEFAULT NULL;
|
||||||
|
|
||||||
|
UPDATE sync_rule SET purge_action = 'delete';
|
||||||
|
|
||||||
|
ALTER TABLE sync_rule
|
||||||
|
ALTER COLUMN purge_action SET NOT NULL;
|
||||||
|
|
||||||
|
INSERT INTO director_schema_migration
|
||||||
|
(schema_version, migration_time)
|
||||||
|
VALUES (172, NOW());
|
|
@ -37,6 +37,7 @@ CREATE TYPE enum_sync_rule_object_type AS ENUM(
|
||||||
'dependency'
|
'dependency'
|
||||||
);
|
);
|
||||||
CREATE TYPE enum_sync_rule_update_policy AS ENUM('merge', 'override', 'ignore', 'update-only');
|
CREATE TYPE enum_sync_rule_update_policy AS ENUM('merge', 'override', 'ignore', 'update-only');
|
||||||
|
CREATE TYPE enum_sync_rule_purge_action AS ENUM('delete', 'disable');
|
||||||
CREATE TYPE enum_sync_property_merge_policy AS ENUM('override', 'merge');
|
CREATE TYPE enum_sync_property_merge_policy AS ENUM('override', 'merge');
|
||||||
CREATE TYPE enum_sync_state AS ENUM(
|
CREATE TYPE enum_sync_state AS ENUM(
|
||||||
'unknown',
|
'unknown',
|
||||||
|
@ -1690,6 +1691,7 @@ CREATE TABLE sync_rule (
|
||||||
object_type enum_sync_rule_object_type NOT NULL,
|
object_type enum_sync_rule_object_type NOT NULL,
|
||||||
update_policy enum_sync_rule_update_policy NOT NULL,
|
update_policy enum_sync_rule_update_policy NOT NULL,
|
||||||
purge_existing enum_boolean NOT NULL DEFAULT 'n',
|
purge_existing enum_boolean NOT NULL DEFAULT 'n',
|
||||||
|
purge_action enum_sync_rule_purge_action NOT NULL,
|
||||||
filter_expression text DEFAULT NULL,
|
filter_expression text DEFAULT NULL,
|
||||||
sync_state enum_sync_state NOT NULL DEFAULT 'unknown',
|
sync_state enum_sync_state NOT NULL DEFAULT 'unknown',
|
||||||
last_error_message text NULL DEFAULT NULL,
|
last_error_message text NULL DEFAULT NULL,
|
||||||
|
@ -2199,4 +2201,4 @@ COMMENT ON COLUMN icinga_scheduled_downtime_range.merge_behaviour IS 'set -> = {
|
||||||
|
|
||||||
INSERT INTO director_schema_migration
|
INSERT INTO director_schema_migration
|
||||||
(schema_version, migration_time)
|
(schema_version, migration_time)
|
||||||
VALUES (171, NOW());
|
VALUES (172, NOW());
|
||||||
|
|
Loading…
Reference in New Issue