From 24431b3dabe234aea7ba84e5750a529ecbe8e911 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 12 Aug 2016 13:42:22 +0200 Subject: [PATCH] Register deprecated methods in the 'Deprecated' namespace refs #12408 --- lib/base/function.hpp | 16 ++++---- lib/base/scriptframe.cpp | 1 + lib/db_ido/db_ido-itl.conf | 14 ++++++- lib/icinga/icinga-itl.conf | 14 ++++++- lib/methods/methods-itl.conf | 74 +++++++++++++++++++++++++++--------- 5 files changed, 89 insertions(+), 30 deletions(-) diff --git a/lib/base/function.hpp b/lib/base/function.hpp index 82d8b152a..05ce6193c 100644 --- a/lib/base/function.hpp +++ b/lib/base/function.hpp @@ -80,8 +80,8 @@ private: void RegisterFunction(void) { \ Function::Ptr sf = new icinga::Function(#ns "#" #name, WrapFunction(callback), false); \ ScriptGlobal::Set(#ns "." #name, sf); \ - Function::Ptr dsf = new icinga::Function("__" #name " (deprecated)", WrapFunction(callback), false, true); \ - ScriptGlobal::Set("System.__" #name, dsf); \ + Function::Ptr dsf = new icinga::Function("Deprecated#" #name " (deprecated)", WrapFunction(callback), false, true); \ + ScriptGlobal::Set("Deprecated.__" #name, dsf); \ } \ INITIALIZE_ONCE_WITH_PRIORITY(RegisterFunction, 10); \ } } } @@ -91,8 +91,8 @@ private: void RegisterFunction(void) { \ Function::Ptr sf = new icinga::Function(#ns "#" #name, WrapFunction(callback), false); \ ScriptGlobal::Set(#ns "." #name, sf); \ - Function::Ptr dsf = new icinga::Function(#name " (deprecated)", WrapFunction(callback), false, true); \ - ScriptGlobal::Set(#name, dsf); \ + Function::Ptr dsf = new icinga::Function("Deprecated#" #name " (deprecated)", WrapFunction(callback), false, true); \ + ScriptGlobal::Set("Deprecated." #name, dsf); \ } \ INITIALIZE_ONCE_WITH_PRIORITY(RegisterFunction, 10); \ } } } @@ -111,8 +111,8 @@ private: void RegisterFunction(void) { \ Function::Ptr sf = new icinga::Function(#ns "#" #name, WrapFunction(callback), true); \ ScriptGlobal::Set(#ns "." #name, sf); \ - Function::Ptr dsf = new icinga::Function("__" #name " (deprecated)", WrapFunction(callback), true, true); \ - ScriptGlobal::Set("System.__" #name, dsf); \ + Function::Ptr dsf = new icinga::Function("Deprecated#__" #name " (deprecated)", WrapFunction(callback), true, true); \ + ScriptGlobal::Set("Deprecated.__" #name, dsf); \ } \ INITIALIZE_ONCE_WITH_PRIORITY(RegisterFunction, 10); \ } } } @@ -122,8 +122,8 @@ private: void RegisterFunction(void) { \ Function::Ptr sf = new icinga::Function(#ns "#" #name, WrapFunction(callback), true); \ ScriptGlobal::Set(#ns "." #name, sf); \ - Function::Ptr dsf = new icinga::Function(#name " (deprecated)", WrapFunction(callback), true, true); \ - ScriptGlobal::Set(#name, dsf); \ + Function::Ptr dsf = new icinga::Function("Deprecated#" #name " (deprecated)", WrapFunction(callback), true, true); \ + ScriptGlobal::Set("Deprecated." #name, dsf); \ } \ INITIALIZE_ONCE_WITH_PRIORITY(RegisterFunction, 10); \ } } } diff --git a/lib/base/scriptframe.cpp b/lib/base/scriptframe.cpp index cd2ec8e23..643cc5527 100644 --- a/lib/base/scriptframe.cpp +++ b/lib/base/scriptframe.cpp @@ -112,6 +112,7 @@ Array::Ptr ScriptFrame::GetImports(void) if (!m_Imports) { m_Imports = new Array(); m_Imports->Add(ScriptGlobal::Get("System")); + m_Imports->Add(ScriptGlobal::Get("Deprecated")); } return m_Imports; diff --git a/lib/db_ido/db_ido-itl.conf b/lib/db_ido/db_ido-itl.conf index 0ff414d24..c69363805 100644 --- a/lib/db_ido/db_ido-itl.conf +++ b/lib/db_ido/db_ido-itl.conf @@ -18,11 +18,21 @@ ******************************************************************************/ assert(Internal.run_with_activation_context(function() { + var _Internal = Internal.clone() + template CheckCommand "ido-check-command" { - execute = Internal.IdoCheck + execute = _Internal.IdoCheck } - object CheckCommand "ido" { + object CheckCommand "ido" use (_Internal) { import "ido-check-command" } })) + +var methods = [ + "IdoCheck" +] + +for (method in methods) { + Internal.remove(method) +} diff --git a/lib/icinga/icinga-itl.conf b/lib/icinga/icinga-itl.conf index 17b23dac3..75c3297e4 100644 --- a/lib/icinga/icinga-itl.conf +++ b/lib/icinga/icinga-itl.conf @@ -18,7 +18,17 @@ ******************************************************************************/ assert(Internal.run_with_activation_context(function() { - template TimePeriod "legacy-timeperiod" { - update = Internal.LegacyTimePeriod + var _Internal = Internal.clone() + + template TimePeriod "legacy-timeperiod" use (_Internal) { + update = _Internal.LegacyTimePeriod } })) + +var methods = [ + "LegacyTimePeriod" +] + +for (method in methods) { + Internal.remove(method) +} diff --git a/lib/methods/methods-itl.conf b/lib/methods/methods-itl.conf index eed5dbbf6..4432958e8 100644 --- a/lib/methods/methods-itl.conf +++ b/lib/methods/methods-itl.conf @@ -18,39 +18,77 @@ ******************************************************************************/ assert(Internal.run_with_activation_context(function() { - template CheckCommand "icinga-check-command" { - execute = Internal.IcingaCheck + var _Internal = Internal.clone() + + template CheckCommand "icinga-check-command" use (_Internal) { + execute = _Internal.IcingaCheck + } + + template CheckCommand "cluster-check-command" use (_Internal) { + execute = _Internal.ClusterCheck } - template CheckCommand "cluster-check-command" { - execute = Internal.ClusterCheck + template CheckCommand "cluster-zone-check-command" use (_Internal) { + execute = _Internal.ClusterZoneCheck } - template CheckCommand "cluster-zone-check-command" { - execute = Internal.ClusterZoneCheck + template CheckCommand "plugin-check-command" use (_Internal) { + execute = _Internal.PluginCheck } - template CheckCommand "plugin-check-command" { - execute = Internal.PluginCheck + template CheckCommand "clr-check-command" use (_Internal) { + execute = _Internal.ClrCheck } - template CheckCommand "clr-check-command" { - execute = Internal.ClrCheck + template NotificationCommand "plugin-notification-command" use (_Internal) { + execute = _Internal.PluginNotification } - template NotificationCommand "plugin-notification-command" { - execute = Internal.PluginNotification + template EventCommand "plugin-event-command" use (_Internal) { + execute = _Internal.PluginEvent } - template EventCommand "plugin-event-command" { - execute = Internal.PluginEvent + template CheckCommand "random-check-command" use (_Internal) { + execute = _Internal.RandomCheck } - template CheckCommand "random-check-command" { - execute = Internal.RandomCheck + template CheckCommand "exception-check-command" use (_Internal) { + execute = _Internal.ExceptionCheck } - template CheckCommand "exception-check-command" { - execute = Internal.ExceptionCheck + template CheckCommand "null-check-command" use (_Internal) { + execute = _Internal.NullCheck + } + + template EventCommand "null-event-command" use (_Internal) { + execute = _Internal.NullEvent + } + + template TimePeriod "empty-timeperiod" use (_Internal) { + execute = _Internal.EmptyTimePeriod + } + + template TimePeriod "even-minutes-timeperiod" use (_Internal) { + execute = _Internal.EvenMinutesTimePeriod } })) + +var methods = [ + "IcingaCheck", + "ClusterCheck", + "ClusterZoneCheck", + "PluginCheck", + "ClrCheck", + "PluginNotification", + "PluginEvent", + "RandomCheck", + "ExceptionCheck", + "NullCheck", + "NullEvent", + "EmptyTimePeriod", + "EvenMinutesTimePeriod" +] + +for (method in methods) { + Internal.remove(method) +} -- 2.40.0