UuidLookup: do not enforce service objects

fixes #2487
fixes #2554
This commit is contained in:
Thomas Gelf 2022-06-24 10:36:10 +02:00
parent 4b229c122c
commit 9a0279b111
2 changed files with 12 additions and 3 deletions

View File

@ -11,6 +11,12 @@ v1.10.0 (unreleased)
* You can find issues and feature requests related to this release on our * You can find issues and feature requests related to this release on our
[roadmap](https://github.com/Icinga/icingaweb2-module-director/milestone/27?closed=1) [roadmap](https://github.com/Icinga/icingaweb2-module-director/milestone/27?closed=1)
### User Interface
* FIX: links from Service Previews (Icinga DSL) to templates (#2554)
### REST API
* FIX: addressing service templates by name has been fixed (#2487)
### CLI ### CLI
* FIX: config deploy doesn't try to wait in case of no deployment (#2522) * FIX: config deploy doesn't try to wait in case of no deployment (#2522)
* FEATURE: improved wording for deployment error messages (#2523) * FEATURE: improved wording for deployment error messages (#2523)

View File

@ -8,7 +8,6 @@ use Icinga\Module\Director\Objects\IcingaHost;
use Icinga\Module\Director\Objects\IcingaServiceSet; use Icinga\Module\Director\Objects\IcingaServiceSet;
use Ramsey\Uuid\Uuid; use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface; use Ramsey\Uuid\UuidInterface;
use RuntimeException;
use function is_int; use function is_int;
use function is_resource; use function is_resource;
use function is_string; use function is_string;
@ -22,17 +21,21 @@ class UuidLookup
* @param int|string $key * @param int|string $key
* @param IcingaHost|null $host * @param IcingaHost|null $host
* @param IcingaServiceSet $set * @param IcingaServiceSet $set
* @return ?UuidInterface
*/ */
public static function findServiceUuid( public static function findServiceUuid(
Db $connection, Db $connection,
Branch $branch, Branch $branch,
$objectType, $objectType = null,
$key = null, $key = null,
IcingaHost $host = null, IcingaHost $host = null,
IcingaServiceSet $set = null IcingaServiceSet $set = null
) { ) {
$db = $connection->getDbAdapter(); $db = $connection->getDbAdapter();
$query = $db->select()->from('icinga_service', 'uuid')->where('object_type = ?', $objectType); $query = $db->select()->from('icinga_service', 'uuid');
if ($objectType) {
$query->where('object_type = ?', $objectType);
}
$query = self::addKeyToQuery($connection, $query, $key); $query = self::addKeyToQuery($connection, $query, $key);
if ($host) { if ($host) {
$query->where('host_id = ?', $host->get('id')); $query->where('host_id = ?', $host->get('id'));