IcingaServiceSet: Delete host sets when deleting a set

This allows service sets to be deleted, including their children sets that
are assigned to hosts.

The UI forbids deleting those sets, but we can use it like this for CLI
and purging during sync.
This commit is contained in:
Markus Frosch 2019-02-13 11:18:04 +01:00
parent d4f9f297c2
commit 8fbbe95c8a

View File

@ -110,6 +110,19 @@ class IcingaServiceSet extends IcingaObject
return $services;
}
public function beforeDelete()
{
// check if this is a template, or directly assigned to a host
if ($this->get('host_id') === null) {
// find all host sets and delete them
foreach ($this->fetchHostSets() as $set) {
$set->delete();
}
}
parent::beforeDelete();
}
public function onDelete()
{
$hostId = $this->get('host_id');