IcingaServiceSet: load services by UUID

fixes #2454
This commit is contained in:
Thomas Gelf 2022-01-10 13:31:25 +01:00
parent 274c153837
commit 0fcbc2783b
1 changed files with 6 additions and 8 deletions

View File

@ -6,11 +6,13 @@ use Exception;
use Icinga\Data\Filter\Filter;
use Icinga\Module\Director\Db;
use Icinga\Module\Director\Db\Cache\PrefetchCache;
use Icinga\Module\Director\Db\DbUtil;
use Icinga\Module\Director\DirectorObject\Automation\ExportInterface;
use Icinga\Module\Director\Exception\DuplicateKeyException;
use Icinga\Module\Director\IcingaConfig\IcingaConfig;
use Icinga\Module\Director\Resolver\HostServiceBlacklist;
use InvalidArgumentException;
use Ramsey\Uuid\Uuid;
use RuntimeException;
class IcingaServiceSet extends IcingaObject implements ExportInterface
@ -108,20 +110,16 @@ class IcingaServiceSet extends IcingaObject implements ExportInterface
if ($set->get('id') === null) {
return array();
}
$connection = $this->getConnection();
$db = $this->getDb();
$ids = $db->fetchCol(
$db->select()->from('icinga_service', 'id')
$uuids = $db->fetchCol(
$db->select()->from('icinga_service', 'uuid')
->where('service_set_id = ?', $set->get('id'))
);
$services = array();
foreach ($ids as $id) {
$service = IcingaService::load(array(
'id' => $id,
'object_type' => 'template'
), $connection);
foreach ($uuids as $uuid) {
$service = IcingaService::loadWithUniqueId(Uuid::fromBytes(DbUtil::binaryResult($uuid)), $connection);
$service->set('service_set', null);
$services[$service->getObjectName()] = $service;