MCPcopy Create free account
hub / github.com/Icinga/icinga2 / CalculateConfigHash

Method CalculateConfigHash

lib/db_ido/hostdbobject.cpp:350–422  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

348}
349
350String HostDbObject::CalculateConfigHash(const Dictionary::Ptr& configFields) const
351{
352 String hashData = DbObject::CalculateConfigHash(configFields);
353
354 Host::Ptr host = static_pointer_cast<Host>(GetObject());
355
356 Array::Ptr groups = host->GetGroups();
357
358 if (groups) {
359 groups = groups->ShallowClone();
360 ObjectLock oLock (groups);
361 std::sort(groups->Begin(), groups->End());
362 hashData += DbObject::HashValue(groups);
363 }
364
365 ArrayData parents;
366
367 /* parents */
368 for (const Checkable::Ptr& checkable : host->GetParents()) {
369 Host::Ptr parent = dynamic_pointer_cast<Host>(checkable);
370
371 if (!parent)
372 continue;
373
374 parents.push_back(parent->GetName());
375 }
376
377 std::sort(parents.begin(), parents.end());
378
379 hashData += DbObject::HashValue(new Array(std::move(parents)));
380
381 ArrayData dependencies;
382
383 /* dependencies */
384 for (const Dependency::Ptr& dep : host->GetDependencies()) {
385 Checkable::Ptr parent = dep->GetParent();
386
387 if (!parent)
388 continue;
389
390 dependencies.push_back(new Array({
391 parent->GetName(),
392 dep->GetStateFilter(),
393 dep->GetPeriodRaw()
394 }));
395 }
396
397 std::sort(dependencies.begin(), dependencies.end());
398
399 hashData += DbObject::HashValue(new Array(std::move(dependencies)));
400
401 ArrayData users;
402
403 for (const User::Ptr& user : CompatUtility::GetCheckableNotificationUsers(host)) {
404 users.push_back(user->GetName());
405 }
406
407 std::sort(users.begin(), users.end());

Callers

nothing calls this directly

Calls 11

SHA256Function · 0.85
push_backMethod · 0.80
GetDependenciesMethod · 0.80
ShallowCloneMethod · 0.45
BeginMethod · 0.45
EndMethod · 0.45
GetParentsMethod · 0.45
GetNameMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetParentMethod · 0.45

Tested by

no test coverage detected