From e2696fd75a17901338595dc1a8313f759275a7fc Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Sat, 28 Nov 2020 19:09:58 +0100 Subject: [PATCH] IcingaConfig: remove magic_apply_for This has always been and experimental feature, deprecated since v1.7.0 fixes #1851 --- application/controllers/HostController.php | 23 ------ doc/82-Changelog.md | 1 + .../Director/IcingaConfig/IcingaConfig.php | 73 ------------------- library/Director/Settings.php | 2 - 4 files changed, 1 insertion(+), 98 deletions(-) diff --git a/application/controllers/HostController.php b/application/controllers/HostController.php index fe304ec5..4257066b 100644 --- a/application/controllers/HostController.php +++ b/application/controllers/HostController.php @@ -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); diff --git a/doc/82-Changelog.md b/doc/82-Changelog.md index 64c0ec63..e49e5816 100644 --- a/doc/82-Changelog.md +++ b/doc/82-Changelog.md @@ -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 diff --git a/library/Director/IcingaConfig/IcingaConfig.php b/library/Director/IcingaConfig/IcingaConfig.php index b61a0564..78776bea 100644 --- a/library/Director/IcingaConfig/IcingaConfig.php +++ b/library/Director/IcingaConfig/IcingaConfig.php @@ -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 * diff --git a/library/Director/Settings.php b/library/Director/Settings.php index 45683e40..274e5991 100644 --- a/library/Director/Settings.php +++ b/library/Director/Settings.php @@ -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)',