Db: add 'master' fallback for single-zone setups

This makes life easier for many users with simple setups as it would
silently use a single non-global zone as the preferred deployment
zone per default.

fixes #11228
This commit is contained in:
Thomas Gelf 2016-03-02 23:32:25 +01:00
parent f1c787fa0c
commit 44b9142165

View File

@ -47,7 +47,22 @@ class Db extends DbConnection
public function getMasterZoneName()
{
return $this->getSetting('master_zone', 'master');
if ($zone = $this->getSetting('master_zone')) {
return $zone;
}
$db = $this->db();
$query = $db->select()
->from('icinga_zone', 'object_name')
->where('is_global = ?', 'n');
$zones = $db->fetchCol($query);
if (count($zones) === 1) {
return $zones[0];
}
return 'master';
}
public function getDefaultGlobalZoneName()