Sync(Rule): Allow to sync services of a ServiceSet

This extends the destination key pattern for Sync.

refs #12891
This commit is contained in:
Markus Frosch 2016-11-10 14:05:18 +01:00
parent ddd59ab274
commit 8b5689545c
2 changed files with 17 additions and 1 deletions

View File

@ -349,7 +349,10 @@ class Sync
) as $object) {
if ($object instanceof IcingaService) {
if (! $object->host_id) {
if (strstr($destinationKeyPattern, '${host}') && $object->host_id === null) {
continue;
}
elseif (strstr($destinationKeyPattern, '${service_set}') && $object->service_set_id === null) {
continue;
}
}

View File

@ -267,6 +267,9 @@ class SyncRule extends DbObject
if ($property->destination_field === 'host') {
$hasHost = $property->source_expression;
}
if ($property->destination_field === 'service_set') {
$hasServiceSet = $property->source_expression;
}
if ($property->destination_field === 'object_name') {
$hasObjectName = $property->source_expression;
}
@ -282,6 +285,16 @@ class SyncRule extends DbObject
$this->destinationKeyPattern = '${host}!${object_name}';
}
elseif ($hasServiceSet !== false && $hasObjectName !== false) {
$this->hasCombinedKey = true;
$this->sourceKeyPattern = sprintf(
'%s!%s',
$hasServiceSet,
$hasObjectName
);
$this->destinationKeyPattern = '${service_set}!${object_name}';
}
} elseif ($this->get('object_type') === 'serviceSet') {
$hasHost = false;
$hasObjectName = false;