Sync(Rule): Allow to sync services of a ServiceSet
This extends the destination key pattern for Sync. refs #12891
This commit is contained in:
parent
ddd59ab274
commit
8b5689545c
library/Director
|
@ -349,7 +349,10 @@ class Sync
|
||||||
) as $object) {
|
) as $object) {
|
||||||
|
|
||||||
if ($object instanceof IcingaService) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,6 +267,9 @@ class SyncRule extends DbObject
|
||||||
if ($property->destination_field === 'host') {
|
if ($property->destination_field === 'host') {
|
||||||
$hasHost = $property->source_expression;
|
$hasHost = $property->source_expression;
|
||||||
}
|
}
|
||||||
|
if ($property->destination_field === 'service_set') {
|
||||||
|
$hasServiceSet = $property->source_expression;
|
||||||
|
}
|
||||||
if ($property->destination_field === 'object_name') {
|
if ($property->destination_field === 'object_name') {
|
||||||
$hasObjectName = $property->source_expression;
|
$hasObjectName = $property->source_expression;
|
||||||
}
|
}
|
||||||
|
@ -282,6 +285,16 @@ class SyncRule extends DbObject
|
||||||
|
|
||||||
$this->destinationKeyPattern = '${host}!${object_name}';
|
$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') {
|
} elseif ($this->get('object_type') === 'serviceSet') {
|
||||||
$hasHost = false;
|
$hasHost = false;
|
||||||
$hasObjectName = false;
|
$hasObjectName = false;
|
||||||
|
|
Loading…
Reference in New Issue