IcingaConfig: remove magic_apply_for

This has always been and experimental feature, deprecated since v1.7.0

fixes #1851
This commit is contained in:
Thomas Gelf 2020-11-28 19:09:58 +01:00
parent 6ef8d98594
commit e2696fd75a
4 changed files with 1 additions and 98 deletions

View File

@ -168,16 +168,6 @@ class HostController extends ObjectController
$content->add($table);
}
if ($applied = $host->vars()->get($db->settings()->magic_apply_for)) {
if ($applied instanceof CustomVariableDictionary) {
$table = IcingaHostAppliedForServiceTable::load($host, $applied)
->setTitle($this->translate('Generated from host vars'));
if (count($table)) {
$content->add($table);
}
}
}
/** @var IcingaHost[] $parents */
$parents = IcingaTemplateRepository::instanceByObject($this->object)
->getTemplatesFor($this->object, true);
@ -246,19 +236,6 @@ class HostController extends ObjectController
$content->add($table);
}
/* @deprecated to be removed in 1.8.0 #1850 #1851 */
if ($applied = $host->vars()->get($db->settings()->magic_apply_for)) {
if ($applied instanceof CustomVariableDictionary) {
$table = IcingaHostAppliedForServiceTable::load($host, $applied)
->setReadonly()
->highlightService($service)
->setTitle($this->translate('Generated from host vars'));
if (count($table)) {
$content->add($table);
}
}
}
/** @var IcingaHost[] $parents */
$parents = IcingaTemplateRepository::instanceByObject($this->object)
->getTemplatesFor($this->object, true);

View File

@ -67,6 +67,7 @@ next (will be 1.8.0)
### Icinga Configuration
* FIX: Correctly render Service Dependencies with Array-style parent hosts (#2088)
* REMOVED: magic-apply-for (a hidden deprecated feature) has been removed (#1851)
### Icinga Agent handling
* FIX: Linux Agent installer now fails when unable to retrieve a certificate

View File

@ -509,7 +509,6 @@ class IcingaConfig
"\nconst DirectorStageDir = dirname(dirname(current_filename))\n"
. $this->renderFlappingLogHelper()
. $this->renderHostOverridableVars()
. $this->renderMagicApplyFor() /* @deprecated Will be removed in 1.8.0 - #1850 #1851 */
);
return $this;
@ -575,78 +574,6 @@ if (! globals.contains(DirectorOverrideTemplate)) {
);
}
/**
* @deprecated Will be removed in 1.8.0 - #1850 #1851
* @return string
*/
protected function renderMagicApplyFor()
{
if (! $this->usesMagicApplyFor()) {
return '';
}
$varname = $this->getMagicApplyVarName();
return sprintf(
'
/* DEPRECATED: This feature always was experimental and will be removed in 1.8.0 (see issue #1850 #1851) */
apply Service for (title => params in host.vars["%s"]) {
log(LogWarning, "config", "Director: Magic Apply For was used on Host \"" +
host.name + "\", it is now deprecated and will be removed in Director 1.8.0 (see issue #1850 #1851)")
var override = host.vars["%s_vars"][title]
if (typeof(params["templates"]) in [Array, String]) {
for (tpl in params["templates"]) {
import tpl
}
} else {
import title
}
if (typeof(params.vars) == Dictionary) {
vars += params.vars
}
if (typeof(params["host_name"]) == String) {
host_name = params["host_name"]
}
import DirectorOverrideTemplate
}
',
$varname,
$varname
);
}
/**
* @deprecated Will be removed in 1.8.0 - #1850 #1851
* @return mixed|null
*/
protected function getMagicApplyVarName()
{
return $this->connection->settings()->magic_apply_for;
}
/**
* @deprecated Will be removed in 1.8.0 - #1850 #1851
* @return string
*/
protected function usesMagicApplyFor()
{
$db = $this->db;
$query = $db->select()->from(
array('hv' => 'icinga_host_var'),
array('c' => 'COUNT(*)')
)->where(
'hv.varname = ?',
$this->getMagicApplyVarName()
);
return $db->fetchOne($query);
}
/**
* @param string $checksum
*

View File

@ -13,8 +13,6 @@ class Settings
protected $defaults = [
'default_global_zone' => 'director-global',
'icinga_package_name' => 'director',
/* @deprecated to be removed in 1.8.0 #1850 #1851 */
'magic_apply_for' => '_director_apply_for',
'config_format' => 'v2',
'override_services_varname' => '_override_servicevars',
'override_services_templatename' => 'host var overrides (Director)',