diff --git a/library/Director/CustomVariable/CustomVariables.php b/library/Director/CustomVariable/CustomVariables.php index b3e32920..bb94d951 100644 --- a/library/Director/CustomVariable/CustomVariables.php +++ b/library/Director/CustomVariable/CustomVariables.php @@ -23,6 +23,8 @@ class CustomVariables implements Iterator, Countable, IcingaConfigRenderer private $position = 0; + private $overrideKeyName; + protected $idx = array(); protected static $allTables = array( @@ -111,7 +113,6 @@ class CustomVariables implements Iterator, Countable, IcingaConfigRenderer return array_key_exists($this->position, $this->idx); } - /** * Generic setter * @@ -302,6 +303,12 @@ class CustomVariables implements Iterator, Countable, IcingaConfigRenderer return sha1(implode('|', $sums), true); } + public function setOverrideKeyName($name) + { + $this->overrideKeyName = $name; + return $this; + } + public function toConfigString($renderExpressions = false) { $out = ''; @@ -360,10 +367,18 @@ class CustomVariables implements Iterator, Countable, IcingaConfigRenderer */ protected function renderSingleVar($key, $var, $renderExpressions = false) { - return c::renderKeyValue( - $this->renderKeyName($key), - $var->toConfigStringPrefetchable($renderExpressions) - ); + if ($key === $this->overrideKeyName) { + return c::renderKeyOperatorValue( + $this->renderKeyName($key), + '+=', + $var->toConfigStringPrefetchable($renderExpressions) + ); + } else { + return c::renderKeyValue( + $this->renderKeyName($key), + $var->toConfigStringPrefetchable($renderExpressions) + ); + } } protected function renderKeyName($key) diff --git a/library/Director/Objects/IcingaObject.php b/library/Director/Objects/IcingaObject.php index 3fa6bdfe..19f15a13 100644 --- a/library/Director/Objects/IcingaObject.php +++ b/library/Director/Objects/IcingaObject.php @@ -1220,6 +1220,12 @@ abstract class IcingaObject extends DbObject implements IcingaConfigRenderer } else { $this->vars = CustomVariables::loadForStoredObject($this); } + + if ($this->getShortTableName() === 'host') { + $this->vars->setOverrideKeyName( + $this->getConnection()->settings()->override_services_varname + ); + } } else { $this->vars = new CustomVariables(); }