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

Method InsertObjectDependencies

lib/icingadb/icingadb-objects.cpp:643–1120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

641}
642
643void IcingaDB::InsertObjectDependencies(const ConfigObject::Ptr& object,
644 std::map<RedisConnection::QueryArg, RedisConnection::Query>& hMSets, std::vector<Dictionary::Ptr>& runtimeUpdates, bool runtimeUpdate)
645{
646 auto typeName = GetLowerCaseTypeNameDB(object);
647 String objectKey = GetObjectIdentifier(object);
648 String objectKeyName = typeName + "_id";
649
650 Type::Ptr type = object->GetReflectionType();
651
652 CustomVarObject::Ptr customVarObject = dynamic_pointer_cast<CustomVarObject>(object);
653
654 if (customVarObject) {
655 auto vars(SerializeVars(customVarObject->GetVars()));
656 if (vars) {
657 auto typeCvsKey = GetRedisCustomVarKey(type);
658 auto& typeCvs (hMSets[typeCvsKey]);
659 auto& allCvs (hMSets[CONFIG_REDIS_KEY_PREFIX "customvar"]);
660
661 ObjectLock varsLock(vars);
662 Array::Ptr varsArray(new Array);
663
664 varsArray->Reserve(vars->GetLength());
665
666 for (auto& kv : vars) {
667 if (runtimeUpdate || m_DumpedGlobals.CustomVar.IsNew(kv.first)) {
668 allCvs.emplace_back(kv.first);
669 allCvs.emplace_back(JsonEncode(kv.second));
670
671 if (runtimeUpdate) {
672 AddObjectDataToRuntimeUpdates(runtimeUpdates, kv.first, CONFIG_REDIS_KEY_PREFIX "customvar", kv.second);
673 }
674 }
675
676 String id = HashValue(new Array({m_EnvironmentId, kv.first, object->GetName()}));
677 typeCvs.emplace_back(id);
678
679 Dictionary::Ptr data = new Dictionary({{objectKeyName, objectKey}, {"environment_id", m_EnvironmentId}, {"customvar_id", kv.first}});
680 typeCvs.emplace_back(JsonEncode(data));
681
682 if (runtimeUpdate) {
683 AddObjectDataToRuntimeUpdates(runtimeUpdates, id, std::string(typeCvsKey), data);
684 }
685 }
686 }
687 }
688
689 if (type == Host::TypeInstance || type == Service::TypeInstance) {
690 Checkable::Ptr checkable = static_pointer_cast<Checkable>(object);
691
692 String actionUrl = checkable->GetActionUrl();
693 String notesUrl = checkable->GetNotesUrl();
694 String iconImage = checkable->GetIconImage();
695 if (!actionUrl.IsEmpty()) {
696 auto& actionUrls (hMSets[CONFIG_REDIS_KEY_PREFIX "action:url"]);
697
698 auto id (HashValue(new Array({m_EnvironmentId, actionUrl})));
699
700 if (runtimeUpdate || m_DumpedGlobals.ActionUrl.IsNew(id)) {

Callers

nothing calls this directly

Calls 15

GetRedisCustomVarKeyFunction · 0.85
ReserveMethod · 0.80
IsNewMethod · 0.80
GetUsersMethod · 0.80
GetUserGroupsMethod · 0.80
GetEnvMethod · 0.80
GetReflectionTypeMethod · 0.45
GetLengthMethod · 0.45
GetNameMethod · 0.45
IsEmptyMethod · 0.45
sizeMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected