"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/base/scriptutils.cpp" between
icinga2-2.11.5.tar.gz and icinga2-2.12.0.tar.gz

About: Icinga 2 is an enterprise grade monitoring system which keeps watch over networks and any conceivable network resource.

scriptutils.cpp  (icinga2-2.11.5):scriptutils.cpp  (icinga2-2.12.0)
skipping to change at line 17 skipping to change at line 17
#include "base/utility.hpp" #include "base/utility.hpp"
#include "base/convert.hpp" #include "base/convert.hpp"
#include "base/json.hpp" #include "base/json.hpp"
#include "base/logger.hpp" #include "base/logger.hpp"
#include "base/objectlock.hpp" #include "base/objectlock.hpp"
#include "base/configtype.hpp" #include "base/configtype.hpp"
#include "base/application.hpp" #include "base/application.hpp"
#include "base/dependencygraph.hpp" #include "base/dependencygraph.hpp"
#include "base/initialize.hpp" #include "base/initialize.hpp"
#include "base/namespace.hpp" #include "base/namespace.hpp"
#include "config/configitem.hpp"
#include <boost/regex.hpp> #include <boost/regex.hpp>
#include <algorithm> #include <algorithm>
#include <set> #include <set>
#ifdef _WIN32 #ifdef _WIN32
#include <msi.h> #include <msi.h>
#endif /* _WIN32 */ #endif /* _WIN32 */
using namespace icinga; using namespace icinga;
REGISTER_SAFE_FUNCTION(System, regex, &ScriptUtils::Regex, "pattern:text:mode"); REGISTER_SAFE_FUNCTION(System, regex, &ScriptUtils::Regex, "pattern:text:mode");
skipping to change at line 38 skipping to change at line 39
REGISTER_SAFE_FUNCTION(System, cidr_match, &ScriptUtils::CidrMatch, "pattern:ip: mode"); REGISTER_SAFE_FUNCTION(System, cidr_match, &ScriptUtils::CidrMatch, "pattern:ip: mode");
REGISTER_SAFE_FUNCTION(System, len, &ScriptUtils::Len, "value"); REGISTER_SAFE_FUNCTION(System, len, &ScriptUtils::Len, "value");
REGISTER_SAFE_FUNCTION(System, union, &ScriptUtils::Union, ""); REGISTER_SAFE_FUNCTION(System, union, &ScriptUtils::Union, "");
REGISTER_SAFE_FUNCTION(System, intersection, &ScriptUtils::Intersection, ""); REGISTER_SAFE_FUNCTION(System, intersection, &ScriptUtils::Intersection, "");
REGISTER_FUNCTION(System, log, &ScriptUtils::Log, "severity:facility:value"); REGISTER_FUNCTION(System, log, &ScriptUtils::Log, "severity:facility:value");
REGISTER_FUNCTION(System, range, &ScriptUtils::Range, "start:end:increment"); REGISTER_FUNCTION(System, range, &ScriptUtils::Range, "start:end:increment");
REGISTER_FUNCTION(System, exit, &Application::Exit, "status"); REGISTER_FUNCTION(System, exit, &Application::Exit, "status");
REGISTER_SAFE_FUNCTION(System, typeof, &ScriptUtils::TypeOf, "value"); REGISTER_SAFE_FUNCTION(System, typeof, &ScriptUtils::TypeOf, "value");
REGISTER_SAFE_FUNCTION(System, keys, &ScriptUtils::Keys, "value"); REGISTER_SAFE_FUNCTION(System, keys, &ScriptUtils::Keys, "value");
REGISTER_SAFE_FUNCTION(System, random, &Utility::Random, ""); REGISTER_SAFE_FUNCTION(System, random, &Utility::Random, "");
REGISTER_SAFE_FUNCTION(System, get_template, &ScriptUtils::GetTemplate, "type:na
me");
REGISTER_SAFE_FUNCTION(System, get_templates, &ScriptUtils::GetTemplates, "type"
);
REGISTER_SAFE_FUNCTION(System, get_object, &ScriptUtils::GetObject, "type:name") ; REGISTER_SAFE_FUNCTION(System, get_object, &ScriptUtils::GetObject, "type:name") ;
REGISTER_SAFE_FUNCTION(System, get_objects, &ScriptUtils::GetObjects, "type"); REGISTER_SAFE_FUNCTION(System, get_objects, &ScriptUtils::GetObjects, "type");
REGISTER_FUNCTION(System, assert, &ScriptUtils::Assert, "value"); REGISTER_FUNCTION(System, assert, &ScriptUtils::Assert, "value");
REGISTER_SAFE_FUNCTION(System, string, &ScriptUtils::CastString, "value"); REGISTER_SAFE_FUNCTION(System, string, &ScriptUtils::CastString, "value");
REGISTER_SAFE_FUNCTION(System, number, &ScriptUtils::CastNumber, "value"); REGISTER_SAFE_FUNCTION(System, number, &ScriptUtils::CastNumber, "value");
REGISTER_SAFE_FUNCTION(System, bool, &ScriptUtils::CastBool, "value"); REGISTER_SAFE_FUNCTION(System, bool, &ScriptUtils::CastBool, "value");
REGISTER_SAFE_FUNCTION(System, get_time, &Utility::GetTime, ""); REGISTER_SAFE_FUNCTION(System, get_time, &Utility::GetTime, "");
REGISTER_SAFE_FUNCTION(System, basename, &Utility::BaseName, "path"); REGISTER_SAFE_FUNCTION(System, basename, &Utility::BaseName, "path");
REGISTER_SAFE_FUNCTION(System, dirname, &Utility::DirName, "path"); REGISTER_SAFE_FUNCTION(System, dirname, &Utility::DirName, "path");
REGISTER_SAFE_FUNCTION(System, getenv, &ScriptUtils::GetEnv, "value"); REGISTER_SAFE_FUNCTION(System, getenv, &ScriptUtils::GetEnv, "value");
skipping to change at line 410 skipping to change at line 413
if (ns) { if (ns) {
ObjectLock olock(ns); ObjectLock olock(ns);
for (const Namespace::Pair& kv : ns) { for (const Namespace::Pair& kv : ns) {
result.push_back(kv.first); result.push_back(kv.first);
} }
} }
return new Array(std::move(result)); return new Array(std::move(result));
} }
static Dictionary::Ptr GetTargetForTemplate(const ConfigItem::Ptr& item)
{
DebugInfo di = item->GetDebugInfo();
return new Dictionary({
{ "name", item->GetName() },
{ "type", item->GetType()->GetName() },
{ "location", new Dictionary({
{ "path", di.Path },
{ "first_line", di.FirstLine },
{ "first_column", di.FirstColumn },
{ "last_line", di.LastLine },
{ "last_column", di.LastColumn }
}) }
});
}
Dictionary::Ptr ScriptUtils::GetTemplate(const Value& vtype, const String& name)
{
Type::Ptr ptype;
if (vtype.IsObjectType<Type>())
ptype = vtype;
else
ptype = Type::GetByName(vtype);
ConfigItem::Ptr item = ConfigItem::GetByTypeAndName(ptype, name);
if (!item || !item->IsAbstract())
return nullptr;
DebugInfo di = item->GetDebugInfo();
return GetTargetForTemplate(item);
}
Array::Ptr ScriptUtils::GetTemplates(const Type::Ptr& type)
{
if (!type)
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid type: Must n
ot be null"));
ArrayData result;
for (const ConfigItem::Ptr& item : ConfigItem::GetItems(type)) {
if (item->IsAbstract())
result.push_back(GetTargetForTemplate(item));
}
return new Array(std::move(result));
}
ConfigObject::Ptr ScriptUtils::GetObject(const Value& vtype, const String& name) ConfigObject::Ptr ScriptUtils::GetObject(const Value& vtype, const String& name)
{ {
Type::Ptr ptype; Type::Ptr ptype;
if (vtype.IsObjectType<Type>()) if (vtype.IsObjectType<Type>())
ptype = vtype; ptype = vtype;
else else
ptype = Type::GetByName(vtype); ptype = Type::GetByName(vtype);
auto *ctype = dynamic_cast<ConfigType *>(ptype.get()); auto *ctype = dynamic_cast<ConfigType *>(ptype.get());
 End of changes. 3 change blocks. 
0 lines changed or deleted 57 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)