IcingaConfig: get rid of hardcoded zone names

This commit is contained in:
Thomas Gelf 2016-02-09 20:43:13 +01:00
parent 543601e5c6
commit 446f378b10
1 changed files with 9 additions and 14 deletions

View File

@ -280,7 +280,12 @@ throw $e;
{ {
$start = microtime(true); $start = microtime(true);
$this->configFile('conf.d/001-director-basics')->prepend( $this->configFile(
sprintf(
'zones.d/%s/001-director-basics',
$this->db()->getDefaultGlobalZoneName()
)
)->prepend(
"\nconst DirectorStageDir = dirname(dirname(current_filename))\n" "\nconst DirectorStageDir = dirname(dirname(current_filename))\n"
); );
@ -375,7 +380,7 @@ throw $e;
$endpoints[] = IcingaEndpoint::create($props); $endpoints[] = IcingaEndpoint::create($props);
$zones[] = IcingaZone::create(array( $zones[] = IcingaZone::create(array(
'object_name' => $name, 'object_name' => $name,
'parent' => $this->getMasterZoneName() 'parent' => $this->db()->getMasterZoneName()
), $this->connection)->setEndpointList(array($name)); ), $this->connection)->setEndpointList(array($name));
} }
@ -396,8 +401,8 @@ throw $e;
{ {
Benchmark::measure(sprintf('Generating %d %s', count($objects), $type)); Benchmark::measure(sprintf('Generating %d %s', count($objects), $type));
if (empty($objects)) return $this; if (empty($objects)) return $this;
$masterZone = $this->getMasterZoneName(); $masterZone = $this->db()->getMasterZoneName();
$globalZone = $this->getGlobalZoneName(); $globalZone = $this->db()->getDefaultGlobalZoneName();
$file = null; $file = null;
foreach ($objects as $object) { foreach ($objects as $object) {
@ -480,16 +485,6 @@ throw $e;
return in_array($type, $types); return in_array($type, $types);
} }
protected function getMasterZoneName()
{
return 'master';
}
protected function getGlobalZoneName()
{
return 'director-global';
}
protected function configFile($name, $suffix = '.conf') protected function configFile($name, $suffix = '.conf')
{ {
$filename = $name . $suffix; $filename = $name . $suffix;