mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 17:24:18 +02:00
Delete newly added Services in Service Set when restoring it from snapshot
The Services which were added into the Service Set after the snapshot was created must be deleted when the Service Set is being restored from the snapshot.
This commit is contained in:
parent
420dfcbdbf
commit
b04fe28932
@ -219,11 +219,13 @@ class IcingaServiceSet extends IcingaObject implements ExportInterface
|
||||
's.*'
|
||||
)->where('service_set_id = ?', $setId);
|
||||
$existingServices = IcingaService::loadAll($db, $sQuery, 'object_name');
|
||||
$serviceNames = [];
|
||||
foreach ($services as $service) {
|
||||
if (isset($service->fields)) {
|
||||
unset($service->fields);
|
||||
}
|
||||
$name = $service->object_name;
|
||||
$serviceNames[] = $name;
|
||||
if (isset($existingServices[$name])) {
|
||||
$existing = $existingServices[$name];
|
||||
$existing->setProperties((array) $service);
|
||||
@ -238,6 +240,12 @@ class IcingaServiceSet extends IcingaObject implements ExportInterface
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($existingServices as $existing) {
|
||||
if (!in_array($existing->getObjectName(), $serviceNames)) {
|
||||
$existing->delete();
|
||||
}
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user