Use GetHostService() instead of casts

refs #4991
This commit is contained in:
Gunnar Beutner 2017-03-21 10:21:51 +01:00 committed by Michael Friedrich
parent 6b48a36192
commit 6178ca3886
1 changed files with 13 additions and 6 deletions

View File

@ -176,12 +176,19 @@ void RedisWriter::SendConfigUpdate(const ConfigObject::Ptr& object, const String
checkSum->Set("name_checksum", CalculateCheckSumString(object->GetName()));
if (object->GetReflectionType() == Host::TypeInstance) {
Host::Ptr host = static_pointer_cast<Host>(object);
checkSum->Set("groups_checksum", CalculateCheckSumGroups(host->GetGroups()));
} else if (object->GetReflectionType() == Service::TypeInstance) {
Service::Ptr service = static_pointer_cast<Service>(object);
// TODO: move this elsewhere
Checkable::Ptr checkable = dynamic_pointer_cast<Checkable>(object);
if (checkable) {
Host::Ptr host;
Service::Ptr service;
tie(host, service) = GetHostService(checkable);
if (service)
checkSum->Set("groups_checksum", CalculateCheckSumGroups(service->GetGroups()));
else
checkSum->Set("groups_checksum", CalculateCheckSumGroups(host->GetGroups()));
}
String checkSumBody = JsonEncode(checkSum);