Make sure functions are registered with the correct prefix

refs #12393
This commit is contained in:
Gunnar Beutner 2016-08-10 16:33:17 +02:00
parent 42818ab758
commit e09fb88cae
15 changed files with 38 additions and 15 deletions

View File

@ -76,6 +76,17 @@ private:
} } }
#define REGISTER_SCRIPTFUNCTION_NS(ns, name, callback) \
namespace { namespace UNIQUE_NAME(sf) { namespace sf ## ns ## name { \
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); \
} \
INITIALIZE_ONCE_WITH_PRIORITY(RegisterFunction, 10); \
} } }
#define REGISTER_SCRIPTFUNCTION_NS_DEPRECATED(ns, name, callback) \
namespace { namespace UNIQUE_NAME(sf) { namespace sf ## ns ## name { \
void RegisterFunction(void) { \
Function::Ptr sf = new icinga::Function(#ns "#" #name, WrapFunction(callback), false); \
@ -96,6 +107,17 @@ private:
} } }
#define REGISTER_SAFE_SCRIPTFUNCTION_NS(ns, name, callback) \
namespace { namespace UNIQUE_NAME(sf) { namespace sf ## ns ## name { \
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); \
} \
INITIALIZE_ONCE_WITH_PRIORITY(RegisterFunction, 10); \
} } }
#define REGISTER_SAFE_SCRIPTFUNCTION_NS_DEPRECATED(ns, name, callback) \
namespace { namespace UNIQUE_NAME(sf) { namespace sf ## ns ## name { \
void RegisterFunction(void) { \
Function::Ptr sf = new icinga::Function(#ns "#" #name, WrapFunction(callback), true); \
@ -105,6 +127,7 @@ private:
} \
INITIALIZE_ONCE_WITH_PRIORITY(RegisterFunction, 10); \
} } }
}
#endif /* SCRIPTFUNCTION_H */

View File

@ -33,7 +33,7 @@
using namespace icinga;
REGISTER_SCRIPTFUNCTION_NS(Internal, IdoCheck, &IdoCheckTask::ScriptFunc);
REGISTER_SCRIPTFUNCTION_NS_DEPRECATED(Internal, IdoCheck, &IdoCheckTask::ScriptFunc);
void IdoCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)

View File

@ -31,7 +31,7 @@
using namespace icinga;
REGISTER_SCRIPTFUNCTION_NS(Internal, LegacyTimePeriod, &LegacyTimePeriod::ScriptFunc);
REGISTER_SCRIPTFUNCTION_NS_DEPRECATED(Internal, LegacyTimePeriod, &LegacyTimePeriod::ScriptFunc);
bool LegacyTimePeriod::IsInTimeRange(tm *begin, tm *end, int stride, tm *reference)
{

View File

@ -39,7 +39,7 @@
using namespace icinga;
REGISTER_SCRIPTFUNCTION_NS(Internal, ClrCheck, &ClrCheckTask::ScriptFunc);
REGISTER_SCRIPTFUNCTION_NS_DEPRECATED(Internal, ClrCheck, &ClrCheckTask::ScriptFunc);
static boost::once_flag l_OnceFlag = BOOST_ONCE_INIT;

View File

@ -34,7 +34,7 @@
using namespace icinga;
REGISTER_SCRIPTFUNCTION_NS(Internal, ClusterCheck, &ClusterCheckTask::ScriptFunc);
REGISTER_SCRIPTFUNCTION_NS_DEPRECATED(Internal, ClusterCheck, &ClusterCheckTask::ScriptFunc);
void ClusterCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)

View File

@ -30,7 +30,7 @@
using namespace icinga;
REGISTER_SCRIPTFUNCTION_NS(Internal, ClusterZoneCheck, &ClusterZoneCheckTask::ScriptFunc);
REGISTER_SCRIPTFUNCTION_NS_DEPRECATED(Internal, ClusterZoneCheck, &ClusterZoneCheckTask::ScriptFunc);
void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)

View File

@ -29,7 +29,7 @@
using namespace icinga;
REGISTER_SCRIPTFUNCTION_NS(Internal, ExceptionCheck, &ExceptionCheckTask::ScriptFunc);
REGISTER_SCRIPTFUNCTION_NS_DEPRECATED(Internal, ExceptionCheck, &ExceptionCheckTask::ScriptFunc);
void ExceptionCheckTask::ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)

View File

@ -30,7 +30,7 @@
using namespace icinga;
REGISTER_SCRIPTFUNCTION_NS(Internal, IcingaCheck, &IcingaCheckTask::ScriptFunc);
REGISTER_SCRIPTFUNCTION_NS_DEPRECATED(Internal, IcingaCheck, &IcingaCheckTask::ScriptFunc);
void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)

View File

@ -30,7 +30,7 @@
using namespace icinga;
REGISTER_SCRIPTFUNCTION_NS(Internal, NullCheck, &NullCheckTask::ScriptFunc);
REGISTER_SCRIPTFUNCTION_NS_DEPRECATED(Internal, NullCheck, &NullCheckTask::ScriptFunc);
void NullCheckTask::ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)

View File

@ -23,7 +23,7 @@
using namespace icinga;
REGISTER_SCRIPTFUNCTION_NS(Internal, NullEvent, &NullEventTask::ScriptFunc);
REGISTER_SCRIPTFUNCTION_NS_DEPRECATED(Internal, NullEvent, &NullEventTask::ScriptFunc);
void NullEventTask::ScriptFunc(const Checkable::Ptr&, const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)
{ }

View File

@ -34,7 +34,7 @@
using namespace icinga;
REGISTER_SCRIPTFUNCTION_NS(Internal, PluginCheck, &PluginCheckTask::ScriptFunc);
REGISTER_SCRIPTFUNCTION_NS_DEPRECATED(Internal, PluginCheck, &PluginCheckTask::ScriptFunc);
void PluginCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr,
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)

View File

@ -32,7 +32,7 @@
using namespace icinga;
REGISTER_SCRIPTFUNCTION_NS(Internal, PluginEvent, &PluginEventTask::ScriptFunc);
REGISTER_SCRIPTFUNCTION_NS_DEPRECATED(Internal, PluginEvent, &PluginEventTask::ScriptFunc);
void PluginEventTask::ScriptFunc(const Checkable::Ptr& checkable,
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)

View File

@ -33,7 +33,7 @@
using namespace icinga;
REGISTER_SCRIPTFUNCTION_NS(Internal, PluginNotification, &PluginNotificationTask::ScriptFunc);
REGISTER_SCRIPTFUNCTION_NS_DEPRECATED(Internal, PluginNotification, &PluginNotificationTask::ScriptFunc);
void PluginNotificationTask::ScriptFunc(const Notification::Ptr& notification,
const User::Ptr& user, const CheckResult::Ptr& cr, int itype,

View File

@ -30,7 +30,7 @@
using namespace icinga;
REGISTER_SCRIPTFUNCTION_NS(Internal, RandomCheck, &RandomCheckTask::ScriptFunc);
REGISTER_SCRIPTFUNCTION_NS_DEPRECATED(Internal, RandomCheck, &RandomCheckTask::ScriptFunc);
void RandomCheckTask::ScriptFunc(const Checkable::Ptr& service, const CheckResult::Ptr& cr,
const Dictionary::Ptr& resolvedMacros, bool useResolvedMacros)

View File

@ -22,8 +22,8 @@
using namespace icinga;
REGISTER_SCRIPTFUNCTION_NS(Internal, EmptyTimePeriod, &TimePeriodTask::EmptyTimePeriodUpdate);
REGISTER_SCRIPTFUNCTION_NS(Internal, EvenMinutesTimePeriod, &TimePeriodTask::EvenMinutesTimePeriodUpdate);
REGISTER_SCRIPTFUNCTION_NS_DEPRECATED(Internal, EmptyTimePeriod, &TimePeriodTask::EmptyTimePeriodUpdate);
REGISTER_SCRIPTFUNCTION_NS_DEPRECATED(Internal, EvenMinutesTimePeriod, &TimePeriodTask::EvenMinutesTimePeriodUpdate);
Array::Ptr TimePeriodTask::EmptyTimePeriodUpdate(const TimePeriod::Ptr&, double, double)
{