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

Method OnConfigUpdateHeavy

lib/db_ido/hostdbobject.cpp:146–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146void HostDbObject::OnConfigUpdateHeavy()
147{
148 Host::Ptr host = static_pointer_cast<Host>(GetObject());
149
150 /* groups */
151 Array::Ptr groups = host->GetGroups();
152
153 std::vector<DbQuery> queries;
154
155 DbQuery query1;
156 query1.Table = DbType::GetByName("HostGroup")->GetTable() + "_members";
157 query1.Type = DbQueryDelete;
158 query1.Category = DbCatConfig;
159 query1.WhereCriteria = new Dictionary();
160 query1.WhereCriteria->Set("host_object_id", host);
161 queries.emplace_back(std::move(query1));
162
163 if (groups) {
164 ObjectLock olock(groups);
165 for (String groupName : groups) {
166 HostGroup::Ptr group = HostGroup::GetByName(groupName);
167
168 DbQuery query2;
169 query2.Table = DbType::GetByName("HostGroup")->GetTable() + "_members";
170 query2.Type = DbQueryInsert;
171 query2.Category = DbCatConfig;
172 query2.Fields = new Dictionary({
173 { "instance_id", 0 }, /* DbConnection class fills in real ID */
174 { "hostgroup_id", DbValue::FromObjectInsertID(group) },
175 { "host_object_id", host }
176 });
177 query2.WhereCriteria = new Dictionary({
178 { "instance_id", 0 }, /* DbConnection class fills in real ID */
179 { "hostgroup_id", DbValue::FromObjectInsertID(group) },
180 { "host_object_id", host }
181 });
182 queries.emplace_back(std::move(query2));
183 }
184 }
185
186 DbObject::OnMultipleQueries(queries);
187
188 queries.clear();
189
190 DbQuery query2;
191 query2.Table = GetType()->GetTable() + "_parenthosts";
192 query2.Type = DbQueryDelete;
193 query2.Category = DbCatConfig;
194 query2.WhereCriteria = new Dictionary({
195 { GetType()->GetTable() + "_id", DbValue::FromObjectInsertID(GetObject()) }
196 });
197 queries.emplace_back(std::move(query2));
198
199 /* parents */
200 for (const Checkable::Ptr& checkable : host->GetParents()) {
201 Host::Ptr parent = dynamic_pointer_cast<Host>(checkable);
202
203 if (!parent)

Callers

nothing calls this directly

Calls 9

LogClass · 0.85
GetTableMethod · 0.80
GetDependenciesMethod · 0.80
SetMethod · 0.45
clearMethod · 0.45
GetParentsMethod · 0.45
GetNameMethod · 0.45
GetParentMethod · 0.45
GetPeriodMethod · 0.45

Tested by

no test coverage detected