HostGroupMembershipResolver: handle single groups
Formerly this worked only with apply rules, now this also respects single host/ group assignments. fixes #832
This commit is contained in:
parent
0e759fb2f6
commit
aa3a8987ba
|
@ -372,6 +372,10 @@ class HostGroupMembershipResolver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($this->fetchMissingSingleAssignments() as $row) {
|
||||||
|
$mappings[$row->hostgroup_id][$row->host_id] = $row->host_id;
|
||||||
|
}
|
||||||
|
|
||||||
$this->newMappings = $mappings;
|
$this->newMappings = $mappings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -407,6 +411,26 @@ class HostGroupMembershipResolver
|
||||||
return $this->db->fetchPairs($query);
|
return $this->db->fetchPairs($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function fetchMissingSingleAssignments()
|
||||||
|
{
|
||||||
|
$query = $this->db->select()->from(
|
||||||
|
array('hgh' => 'icinga_hostgroup_host'),
|
||||||
|
array(
|
||||||
|
'host_id',
|
||||||
|
'hostgroup_id',
|
||||||
|
)
|
||||||
|
)->joinLeft(
|
||||||
|
array('hghr' => 'icinga_hostgroup_host_resolved'),
|
||||||
|
'hgh.host_id = hghr.host_id AND hgh.hostgroup_id = hghr.hostgroup_id',
|
||||||
|
array()
|
||||||
|
)->where('hghr.host_id IS NULL');
|
||||||
|
|
||||||
|
$this->addMembershipWhere($query, 'hgh.host_id', $this->hosts);
|
||||||
|
$this->addMembershipWhere($query, 'hgh.hostgroup_id', $this->hostgroups);
|
||||||
|
|
||||||
|
return $this->db->fetchAll($query);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue