Skip to content

Commit

Permalink
Merge pull request #1786 from Icinga/feature/delete-service-set-children
Browse files Browse the repository at this point in the history
IcingaServiceSet: Delete host sets when deleting a set
  • Loading branch information
lazyfrosch authored Mar 26, 2019
2 parents eee3372 + 1713dee commit 0d3649c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions library/Director/Objects/IcingaServiceSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,19 @@ public static function import($plain, Db $db, $replace = false)
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
*/
Expand Down

0 comments on commit 0d3649c

Please sign in to comment.