IcingaConfig: improve override constant usage

This commit is contained in:
Thomas Gelf 2016-09-08 20:24:54 +00:00
parent 646a7dc067
commit 2c7c54a15d
2 changed files with 9 additions and 12 deletions

View File

@ -470,9 +470,10 @@ class IcingaConfig
return sprintf( return sprintf(
' '
const DirectorVarsOverride = "%s" const DirectorOverrideVars = "%s"
const DirectorOverrideTemplate = "%s"
template Service "%s" { template Service DirectorOverrideTemplate {
/** /**
* Seems that host is missing when used in a service object, works fine for * Seems that host is missing when used in a service object, works fine for
* apply rules * apply rules
@ -482,9 +483,9 @@ template Service "%s" {
} }
if (vars) { if (vars) {
vars += host.vars[DirectorVarsOverride][name] vars += host.vars[DirectorOverrideVars][name]
} else { } else {
vars = host.vars[DirectorVarsOverride][name] vars = host.vars[DirectorOverrideVars][name]
} }
} }
', ',
@ -523,12 +524,11 @@ apply Service for (title => params in host.vars["%s"]) {
host_name = params["host_name"] host_name = params["host_name"]
} }
import "%s" import DirectorOverrideTemplate
} }
', ',
$varname, $varname,
$varname, $varname
$this->connection->settings()->override_services_templatename
); );
} }

View File

@ -166,7 +166,7 @@ class IcingaService extends IcingaObject
protected function renderSuffix() protected function renderSuffix()
{ {
if ($this->isApplyRule()) { if ($this->isApplyRule() || $this->usesVarOverrides()) {
return $this->renderImportHostVarOverrides() . parent::renderSuffix(); return $this->renderImportHostVarOverrides() . parent::renderSuffix();
} else { } else {
return parent::renderSuffix(); return parent::renderSuffix();
@ -181,10 +181,7 @@ class IcingaService extends IcingaObject
); );
} }
return sprintf( return "\n import DirectorOverrideTemplate\n";
"\n import \"%s\"\n",
$this->connection->settings()->override_services_templatename
);
} }
protected function renderCustomExtensions() protected function renderCustomExtensions()