mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-29 16:44:29 +02:00
Only use the type for commands in the object identifier checksum
This commit is contained in:
parent
c70316a835
commit
de99d68351
@ -187,7 +187,7 @@ void RedisWriter::SendConfigUpdate(const ConfigObject::Ptr& object, bool useTran
|
|||||||
Type::Ptr type = object->GetReflectionType();
|
Type::Ptr type = object->GetReflectionType();
|
||||||
|
|
||||||
String typeName = type->GetName().ToLower();
|
String typeName = type->GetName().ToLower();
|
||||||
String objectKey = GetIdentifier(object);
|
String objectKey = GetObjectIdentifier(object);
|
||||||
|
|
||||||
std::set<String> propertiesBlacklist ({"name", "__name", "package", "source_location", "templates"});
|
std::set<String> propertiesBlacklist ({"name", "__name", "package", "source_location", "templates"});
|
||||||
|
|
||||||
@ -202,14 +202,14 @@ void RedisWriter::SendConfigUpdate(const ConfigObject::Ptr& object, bool useTran
|
|||||||
auto endpointZone (endpoint->GetZone());
|
auto endpointZone (endpoint->GetZone());
|
||||||
|
|
||||||
if (endpointZone) {
|
if (endpointZone) {
|
||||||
checkSums->Set("zone_checksum", GetIdentifier(endpointZone));
|
checkSums->Set("zone_checksum", GetObjectIdentifier(endpointZone));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* 'zone' is available for all config objects, therefore calculate the checksum. */
|
/* 'zone' is available for all config objects, therefore calculate the checksum. */
|
||||||
auto zone (static_pointer_cast<Zone>(object->GetZone()));
|
auto zone (static_pointer_cast<Zone>(object->GetZone()));
|
||||||
|
|
||||||
if (zone)
|
if (zone)
|
||||||
checkSums->Set("zone_checksum", GetIdentifier(zone));
|
checkSums->Set("zone_checksum", GetObjectIdentifier(zone));
|
||||||
}
|
}
|
||||||
|
|
||||||
User::Ptr user = dynamic_pointer_cast<User>(object);
|
User::Ptr user = dynamic_pointer_cast<User>(object);
|
||||||
@ -231,7 +231,7 @@ void RedisWriter::SendConfigUpdate(const ConfigObject::Ptr& object, bool useTran
|
|||||||
ObjectLock groupChecksumsLock (groupChecksums);
|
ObjectLock groupChecksumsLock (groupChecksums);
|
||||||
|
|
||||||
for (auto group : groups) {
|
for (auto group : groups) {
|
||||||
groupChecksums->Add(GetIdentifier((*getGroup)(group.Get<String>())));
|
groupChecksums->Add(GetObjectIdentifier((*getGroup)(group.Get<String>())));
|
||||||
}
|
}
|
||||||
|
|
||||||
checkSums->Set("group_checksums", groupChecksums);
|
checkSums->Set("group_checksums", groupChecksums);
|
||||||
@ -257,7 +257,7 @@ void RedisWriter::SendConfigUpdate(const ConfigObject::Ptr& object, bool useTran
|
|||||||
getGroup = &::GetServiceGroup;
|
getGroup = &::GetServiceGroup;
|
||||||
|
|
||||||
/* Calculate the host_checksum */
|
/* Calculate the host_checksum */
|
||||||
checkSums->Set("host_checksum", GetIdentifier(host));
|
checkSums->Set("host_checksum", GetObjectIdentifier(host));
|
||||||
} else {
|
} else {
|
||||||
groups = host->GetGroups();
|
groups = host->GetGroups();
|
||||||
getGroup = &::GetHostGroup;
|
getGroup = &::GetHostGroup;
|
||||||
@ -271,7 +271,7 @@ void RedisWriter::SendConfigUpdate(const ConfigObject::Ptr& object, bool useTran
|
|||||||
ObjectLock groupChecksumsLock (groupChecksums);
|
ObjectLock groupChecksumsLock (groupChecksums);
|
||||||
|
|
||||||
for (auto group : groups) {
|
for (auto group : groups) {
|
||||||
groupChecksums->Add(GetIdentifier((*getGroup)(group.Get<String>())));
|
groupChecksums->Add(GetObjectIdentifier((*getGroup)(group.Get<String>())));
|
||||||
}
|
}
|
||||||
|
|
||||||
checkSums->Set("group_checksums", groupChecksums);
|
checkSums->Set("group_checksums", groupChecksums);
|
||||||
@ -280,15 +280,15 @@ void RedisWriter::SendConfigUpdate(const ConfigObject::Ptr& object, bool useTran
|
|||||||
Endpoint::Ptr commandEndpoint = checkable->GetCommandEndpoint();
|
Endpoint::Ptr commandEndpoint = checkable->GetCommandEndpoint();
|
||||||
|
|
||||||
if (commandEndpoint)
|
if (commandEndpoint)
|
||||||
checkSums->Set("command_endpoint_checksum", GetIdentifier(commandEndpoint));
|
checkSums->Set("command_endpoint_checksum", GetObjectIdentifier(commandEndpoint));
|
||||||
|
|
||||||
/* *_command_checksum */
|
/* *_command_checksum */
|
||||||
checkSums->Set("check_command_checksum", GetIdentifier(checkable->GetCheckCommand()));
|
checkSums->Set("check_command_checksum", GetObjectIdentifier(checkable->GetCheckCommand()));
|
||||||
|
|
||||||
EventCommand::Ptr eventCommand = checkable->GetEventCommand();
|
EventCommand::Ptr eventCommand = checkable->GetEventCommand();
|
||||||
|
|
||||||
if (eventCommand)
|
if (eventCommand)
|
||||||
checkSums->Set("event_command_checksum", GetIdentifier(eventCommand));
|
checkSums->Set("event_command_checksum", GetObjectIdentifier(eventCommand));
|
||||||
|
|
||||||
/* *_url_checksum, icon_image_checksum */
|
/* *_url_checksum, icon_image_checksum */
|
||||||
String actionUrl = checkable->GetActionUrl();
|
String actionUrl = checkable->GetActionUrl();
|
||||||
@ -321,7 +321,7 @@ void RedisWriter::SendConfigUpdate(const ConfigObject::Ptr& object, bool useTran
|
|||||||
Zone::Ptr parentZone = zone->GetParent();
|
Zone::Ptr parentZone = zone->GetParent();
|
||||||
|
|
||||||
if (parentZone)
|
if (parentZone)
|
||||||
checkSums->Set("parent_checksum", GetIdentifier(parentZone));
|
checkSums->Set("parent_checksum", GetObjectIdentifier(parentZone));
|
||||||
} else {
|
} else {
|
||||||
/* zone_checksum for endpoints already is calculated above. */
|
/* zone_checksum for endpoints already is calculated above. */
|
||||||
|
|
||||||
@ -381,7 +381,7 @@ void RedisWriter::SendConfigUpdate(const ConfigObject::Ptr& object, bool useTran
|
|||||||
ObjectLock includeChecksumsLock (includeChecksums);
|
ObjectLock includeChecksumsLock (includeChecksums);
|
||||||
|
|
||||||
for (auto include : includes) {
|
for (auto include : includes) {
|
||||||
includeChecksums->Add(GetIdentifier((*getInclude)(include.Get<String>())));
|
includeChecksums->Add(GetObjectIdentifier((*getInclude)(include.Get<String>())));
|
||||||
}
|
}
|
||||||
|
|
||||||
checkSums->Set("include_checksums", includeChecksums);
|
checkSums->Set("include_checksums", includeChecksums);
|
||||||
@ -401,7 +401,7 @@ void RedisWriter::SendConfigUpdate(const ConfigObject::Ptr& object, bool useTran
|
|||||||
ObjectLock excludeChecksumsLock (excludeChecksums);
|
ObjectLock excludeChecksumsLock (excludeChecksums);
|
||||||
|
|
||||||
for (auto exclude : excludes) {
|
for (auto exclude : excludes) {
|
||||||
excludeChecksums->Add(GetIdentifier((*getExclude)(exclude.Get<String>())));
|
excludeChecksums->Add(GetObjectIdentifier((*getExclude)(exclude.Get<String>())));
|
||||||
}
|
}
|
||||||
|
|
||||||
checkSums->Set("exclude_checksums", excludeChecksums);
|
checkSums->Set("exclude_checksums", excludeChecksums);
|
||||||
@ -459,7 +459,7 @@ void RedisWriter::SendConfigDelete(const ConfigObject::Ptr& object)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
String typeName = object->GetReflectionType()->GetName().ToLower();
|
String typeName = object->GetReflectionType()->GetName().ToLower();
|
||||||
String objectKey = GetIdentifier(object);
|
String objectKey = GetObjectIdentifier(object);
|
||||||
|
|
||||||
ExecuteQueries({
|
ExecuteQueries({
|
||||||
{ "DEL", m_PrefixConfigObject + typeName + ":" + objectKey },
|
{ "DEL", m_PrefixConfigObject + typeName + ":" + objectKey },
|
||||||
@ -570,7 +570,7 @@ void RedisWriter::UpdateObjectAttrs(const String& keyPrefix, const ConfigObject:
|
|||||||
String typeName = type->GetName().ToLower();
|
String typeName = type->GetName().ToLower();
|
||||||
|
|
||||||
/* Use the name checksum as unique key. */
|
/* Use the name checksum as unique key. */
|
||||||
String objectKey = GetIdentifier(object);
|
String objectKey = GetObjectIdentifier(object);
|
||||||
|
|
||||||
std::vector<std::vector<String> > queries;
|
std::vector<std::vector<String> > queries;
|
||||||
|
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
#include "redis/rediswriter.hpp"
|
#include "redis/rediswriter.hpp"
|
||||||
#include "icinga/customvarobject.hpp"
|
#include "icinga/customvarobject.hpp"
|
||||||
|
#include "icinga/checkcommand.hpp"
|
||||||
|
#include "icinga/notificationcommand.hpp"
|
||||||
|
#include "icinga/eventcommand.hpp"
|
||||||
#include "base/object-packer.hpp"
|
#include "base/object-packer.hpp"
|
||||||
#include "base/logger.hpp"
|
#include "base/logger.hpp"
|
||||||
#include "base/serializer.hpp"
|
#include "base/serializer.hpp"
|
||||||
@ -49,9 +52,14 @@ String RedisWriter::GetEnvironment()
|
|||||||
return ScriptGlobal::Get("Environment", &l_DefaultEnv);
|
return ScriptGlobal::Get("Environment", &l_DefaultEnv);
|
||||||
}
|
}
|
||||||
|
|
||||||
String RedisWriter::GetIdentifier(const ConfigObject::Ptr& object)
|
String RedisWriter::GetObjectIdentifier(const ConfigObject::Ptr& object)
|
||||||
{
|
{
|
||||||
return HashValue((Array::Ptr)new Array({GetEnvironment(), object->GetReflectionType()->GetName(), object->GetName()}));
|
Type::Ptr type = object->GetReflectionType();
|
||||||
|
|
||||||
|
if (type == CheckCommand::TypeInstance || type == NotificationCommand::TypeInstance || type == EventCommand::TypeInstance)
|
||||||
|
return HashValue((Array::Ptr)new Array({GetEnvironment(), type->GetName(), object->GetName()}));
|
||||||
|
else
|
||||||
|
return HashValue((Array::Ptr)new Array({GetEnvironment(), object->GetName()}));
|
||||||
}
|
}
|
||||||
|
|
||||||
String RedisWriter::CalculateCheckSumString(const String& str)
|
String RedisWriter::CalculateCheckSumString(const String& str)
|
||||||
|
@ -77,7 +77,7 @@ private:
|
|||||||
/* utilities */
|
/* utilities */
|
||||||
static String FormatCheckSumBinary(const String& str);
|
static String FormatCheckSumBinary(const String& str);
|
||||||
|
|
||||||
static String GetIdentifier(const ConfigObject::Ptr& object);
|
static String GetObjectIdentifier(const ConfigObject::Ptr& object);
|
||||||
static String GetEnvironment();
|
static String GetEnvironment();
|
||||||
static String CalculateCheckSumString(const String& str);
|
static String CalculateCheckSumString(const String& str);
|
||||||
static String CalculateCheckSumArray(const Array::Ptr& arr);
|
static String CalculateCheckSumArray(const Array::Ptr& arr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user