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

Method InitChildParentReferences

lib/icinga/dependency.cpp:221–266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

219}
220
221void Dependency::InitChildParentReferences()
222{
223 Host::Ptr childHost = Host::GetByName(GetChildHostName());
224
225 if (childHost) {
226 if (GetChildServiceName().IsEmpty()) {
227 m_Child = childHost;
228 } else {
229 m_Child = childHost->GetServiceByShortName(GetChildServiceName());
230 if (!m_Child) {
231 BOOST_THROW_EXCEPTION(ScriptError(
232 "Dependency '" + GetName() + "' references child service '" + GetChildServiceName() + "' on '" +
233 GetChildHostName() + "' which doesn't exist.",
234 GetDebugInfo()
235 ));
236 }
237 }
238 } else {
239 BOOST_THROW_EXCEPTION(ScriptError(
240 "Dependency '" + GetName() + "' references child host '" + GetChildHostName() + "' which doesn't exist.",
241 GetDebugInfo()
242 ));
243 }
244
245 Host::Ptr parentHost = Host::GetByName(GetParentHostName());
246
247 if (parentHost) {
248 if (GetParentServiceName().IsEmpty()) {
249 m_Parent = parentHost;
250 } else {
251 m_Parent = parentHost->GetServiceByShortName(GetParentServiceName());
252 if (!m_Parent) {
253 BOOST_THROW_EXCEPTION(ScriptError(
254 "Dependency '" + GetName() + "' references parent service '" + GetParentServiceName() + "' on '" +
255 GetParentHostName() + "' which doesn't exist.",
256 GetDebugInfo()
257 ));
258 }
259 }
260 } else {
261 BOOST_THROW_EXCEPTION(ScriptError(
262 "Dependency '" + GetName() + "' references parent host '" + GetParentHostName() + "' which doesn't exist.",
263 GetDebugInfo()
264 ));
265 }
266}
267
268void Dependency::OnAllConfigLoaded()
269{

Callers 1

Calls 3

ScriptErrorClass · 0.85
GetServiceByShortNameMethod · 0.80
IsEmptyMethod · 0.45

Tested by

no test coverage detected