Db: improve master zone detection

This also speeds up config generation
This commit is contained in:
Thomas Gelf 2016-06-29 20:59:37 +02:00
parent 44e1302ba2
commit 5cc28ac4a6

View File

@ -21,6 +21,8 @@ class Db extends DbConnection
protected $settings;
protected $masterZoneName;
protected function db()
{
return $this->getDbAdapter();
@ -60,6 +62,15 @@ class Db extends DbConnection
}
public function getMasterZoneName()
{
if ($this->masterZoneName === null) {
$this->masterZoneName = $this->detectMasterZoneName();
}
return $this->masterZoneName;
}
protected function detectMasterZoneName()
{
if ($zone = $this->getSetting('master_zone')) {
return $zone;
@ -68,6 +79,7 @@ class Db extends DbConnection
$db = $this->db();
$query = $db->select()
->from('icinga_zone', 'object_name')
->where('parent_id IS NULL')
->where('is_global = ?', 'n');
$zones = $db->fetchCol($query);