mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2026-05-28 04:35:53 -04:00
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:
parent
eee3372430
commit
1713dee1c1
1 changed files with 13 additions and 0 deletions
|
|
@ -234,6 +234,19 @@ class IcingaServiceSet extends IcingaObject implements ExportInterface
|
|||
return $object;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Icinga\Exception\NotFoundError
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in a new issue