mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 07:34:15 +02:00
parent
783586978f
commit
d69cb676a7
@ -65,14 +65,34 @@ String IcingaDB::GetEnvironment()
|
|||||||
return ConfigType::GetObjectsByType<IcingaApplication>()[0]->GetEnvironment();
|
return ConfigType::GetObjectsByType<IcingaApplication>()[0]->GetEnvironment();
|
||||||
}
|
}
|
||||||
|
|
||||||
String IcingaDB::GetObjectIdentifier(const ConfigObject::Ptr& object)
|
ArrayData IcingaDB::GetObjectIdentifiersWithoutEnv(const ConfigObject::Ptr& object)
|
||||||
{
|
{
|
||||||
Type::Ptr type = object->GetReflectionType();
|
Type::Ptr type = object->GetReflectionType();
|
||||||
|
|
||||||
if (type == CheckCommand::TypeInstance || type == NotificationCommand::TypeInstance || type == EventCommand::TypeInstance)
|
if (type == CheckCommand::TypeInstance || type == NotificationCommand::TypeInstance || type == EventCommand::TypeInstance)
|
||||||
return HashValue((Array::Ptr)new Array({GetEnvironment(), type->GetName(), object->GetName()}));
|
return {type->GetName(), object->GetName()};
|
||||||
else
|
else
|
||||||
return HashValue((Array::Ptr)new Array({GetEnvironment(), object->GetName()}));
|
return {object->GetName()};
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline
|
||||||
|
std::vector<T> Prepend(std::vector<T>&& haystack)
|
||||||
|
{
|
||||||
|
return std::move(haystack);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T, class Needle, class... Needles>
|
||||||
|
inline
|
||||||
|
std::vector<T> Prepend(Needles&&... needles, Needle&& needle, std::vector<T>&& haystack)
|
||||||
|
{
|
||||||
|
haystack.emplace(haystack.begin(), std::forward<Needle>(needle));
|
||||||
|
return Prepend(std::forward<Needles>(needles)..., std::move(haystack));
|
||||||
|
}
|
||||||
|
|
||||||
|
String IcingaDB::GetObjectIdentifier(const ConfigObject::Ptr& object)
|
||||||
|
{
|
||||||
|
return HashValue(new Array(Prepend(GetEnvironment(), GetObjectIdentifiersWithoutEnv(object))));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const std::set<String> metadataWhitelist ({"package", "source_location", "templates"});
|
static const std::set<String> metadataWhitelist ({"package", "source_location", "templates"});
|
||||||
|
@ -81,6 +81,7 @@ private:
|
|||||||
static String FormatCommandLine(const Value& commandLine);
|
static String FormatCommandLine(const Value& commandLine);
|
||||||
static long long TimestampToMilliseconds(double timestamp);
|
static long long TimestampToMilliseconds(double timestamp);
|
||||||
|
|
||||||
|
static ArrayData GetObjectIdentifiersWithoutEnv(const ConfigObject::Ptr& object);
|
||||||
static String GetObjectIdentifier(const ConfigObject::Ptr& object);
|
static String GetObjectIdentifier(const ConfigObject::Ptr& object);
|
||||||
static String GetEnvironment();
|
static String GetEnvironment();
|
||||||
static Dictionary::Ptr SerializeVars(const CustomVarObject::Ptr& object);
|
static Dictionary::Ptr SerializeVars(const CustomVarObject::Ptr& object);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user