mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-31 01:34:12 +02: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
d4f9f297c2
commit
8fbbe95c8a
@ -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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user