mirror of
https://github.com/Icinga/icinga2.git
synced 2025-04-08 17:05:25 +02:00
Export usergroup(s)_checksum(s)
Warning: ugly code
This commit is contained in:
parent
876d98a13f
commit
d09a435fe3
@ -23,6 +23,7 @@
|
||||
#include "icinga/service.hpp"
|
||||
#include "icinga/hostgroup.hpp"
|
||||
#include "icinga/servicegroup.hpp"
|
||||
#include "icinga/usergroup.hpp"
|
||||
#include "icinga/checkcommand.hpp"
|
||||
#include "icinga/eventcommand.hpp"
|
||||
#include "icinga/notificationcommand.hpp"
|
||||
@ -151,6 +152,11 @@ static ConfigObject::Ptr GetServiceGroup(const String& name)
|
||||
return ConfigObject::GetObject<ServiceGroup>(name);
|
||||
}
|
||||
|
||||
static ConfigObject::Ptr GetUserGroup(const String& name)
|
||||
{
|
||||
return ConfigObject::GetObject<UserGroup>(name);
|
||||
}
|
||||
|
||||
void RedisWriter::SendConfigUpdate(const ConfigObject::Ptr& object, bool useTransaction, bool runtimeUpdate)
|
||||
{
|
||||
AssertOnWorkQueue();
|
||||
@ -189,6 +195,31 @@ void RedisWriter::SendConfigUpdate(const ConfigObject::Ptr& object, bool useTran
|
||||
if (zone)
|
||||
checkSums->Set("zone_checksum", GetIdentifier(zone));
|
||||
|
||||
User::Ptr user = dynamic_pointer_cast<User>(object);
|
||||
|
||||
if (user) {
|
||||
propertiesBlacklist.emplace("groups");
|
||||
|
||||
Array::Ptr groups;
|
||||
ConfigObject::Ptr (*getGroup)(const String& name);
|
||||
|
||||
groups = user->GetGroups();
|
||||
getGroup = &::GetUserGroup;
|
||||
|
||||
checkSums->Set("groups_checksum", CalculateCheckSumGroups(groups));
|
||||
|
||||
Array::Ptr groupChecksums = new Array();
|
||||
|
||||
ObjectLock groupsLock (groups);
|
||||
ObjectLock groupChecksumsLock (groupChecksums);
|
||||
|
||||
for (auto group : groups) {
|
||||
groupChecksums->Add(GetIdentifier((*getGroup)(group.Get<String>())));
|
||||
}
|
||||
|
||||
checkSums->Set("group_checksums", groupChecksums);
|
||||
}
|
||||
|
||||
/* Calculate checkable checksums. */
|
||||
Checkable::Ptr checkable = dynamic_pointer_cast<Checkable>(object);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user