From 193c575e3a4c8798b28c602e3effb8cfe95d1351 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 25 May 2018 19:57:52 +0200 Subject: [PATCH] HostServiceBlacklist: small fixes refs #907 --- library/Director/Db/Cache/PrefetchCache.php | 1 + library/Director/Objects/IcingaService.php | 2 +- library/Director/Resolver/HostServiceBlacklist.php | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/library/Director/Db/Cache/PrefetchCache.php b/library/Director/Db/Cache/PrefetchCache.php index 29ac990d..447098dd 100644 --- a/library/Director/Db/Cache/PrefetchCache.php +++ b/library/Director/Db/Cache/PrefetchCache.php @@ -108,6 +108,7 @@ class PrefetchCache { if ($this->hostServiceBlacklist === null) { $this->hostServiceBlacklist = new HostServiceBlacklist($this->db); + $this->hostServiceBlacklist->preloadMappings(); } return $this->hostServiceBlacklist; diff --git a/library/Director/Objects/IcingaService.php b/library/Director/Objects/IcingaService.php index 56588239..4d6ac9df 100644 --- a/library/Director/Objects/IcingaService.php +++ b/library/Director/Objects/IcingaService.php @@ -413,7 +413,7 @@ class IcingaService extends IcingaObject if (! empty($blacklist)) { if (count($blacklist) === 1) { $output .= sprintf( - " ignore host.name == %s\n", + " ignore where host.name == %s\n", c::renderString($blacklist[0]) ); } else { diff --git a/library/Director/Resolver/HostServiceBlacklist.php b/library/Director/Resolver/HostServiceBlacklist.php index 1f46a542..6ed8cca8 100644 --- a/library/Director/Resolver/HostServiceBlacklist.php +++ b/library/Director/Resolver/HostServiceBlacklist.php @@ -61,6 +61,10 @@ class HostServiceBlacklist public function fetchMappingsForService(IcingaService $service) { + if (! $service->hasBeenLoadedFromDb()) { + return []; + } + $db = $this->db->getDbAdapter(); $query = $db->select()->from(['hsb' => $this->table], [ 'host_name' => 'h.object_name',