HostServiceBlacklist: small fixes

refs #907
This commit is contained in:
Thomas Gelf 2018-05-25 19:57:52 +02:00
parent f88e318dce
commit 193c575e3a
3 changed files with 6 additions and 1 deletions

View File

@ -108,6 +108,7 @@ class PrefetchCache
{ {
if ($this->hostServiceBlacklist === null) { if ($this->hostServiceBlacklist === null) {
$this->hostServiceBlacklist = new HostServiceBlacklist($this->db); $this->hostServiceBlacklist = new HostServiceBlacklist($this->db);
$this->hostServiceBlacklist->preloadMappings();
} }
return $this->hostServiceBlacklist; return $this->hostServiceBlacklist;

View File

@ -413,7 +413,7 @@ class IcingaService extends IcingaObject
if (! empty($blacklist)) { if (! empty($blacklist)) {
if (count($blacklist) === 1) { if (count($blacklist) === 1) {
$output .= sprintf( $output .= sprintf(
" ignore host.name == %s\n", " ignore where host.name == %s\n",
c::renderString($blacklist[0]) c::renderString($blacklist[0])
); );
} else { } else {

View File

@ -61,6 +61,10 @@ class HostServiceBlacklist
public function fetchMappingsForService(IcingaService $service) public function fetchMappingsForService(IcingaService $service)
{ {
if (! $service->hasBeenLoadedFromDb()) {
return [];
}
$db = $this->db->getDbAdapter(); $db = $this->db->getDbAdapter();
$query = $db->select()->from(['hsb' => $this->table], [ $query = $db->select()->from(['hsb' => $this->table], [
'host_name' => 'h.object_name', 'host_name' => 'h.object_name',