2026-01-27 09:06:40 -05:00
|
|
|
// SPDX-FileCopyrightText: 2012 Icinga GmbH <https://icinga.com>
|
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2014-10-17 13:44:31 -04:00
|
|
|
|
2014-05-25 10:23:35 -04:00
|
|
|
#include "icinga/customvarobject.hpp"
|
|
|
|
|
#include "icinga/checkable.hpp"
|
2015-08-25 07:53:43 -04:00
|
|
|
#impl_include "icinga/service.hpp"
|
2014-02-27 05:05:55 -05:00
|
|
|
|
2015-08-04 08:47:44 -04:00
|
|
|
library icinga;
|
|
|
|
|
|
2014-02-27 05:05:55 -05:00
|
|
|
namespace icinga
|
|
|
|
|
{
|
|
|
|
|
|
2014-04-05 16:17:20 -04:00
|
|
|
code {{{
|
2017-12-31 01:22:16 -05:00
|
|
|
class DependencyNameComposer : public NameComposer
|
2014-04-05 16:17:20 -04:00
|
|
|
{
|
|
|
|
|
public:
|
2025-05-05 03:12:41 -04:00
|
|
|
virtual String MakeName(const String& shortName, const Object::Ptr& context) const override;
|
|
|
|
|
virtual Dictionary::Ptr ParseName(const String& name) const override;
|
2014-04-05 16:17:20 -04:00
|
|
|
};
|
|
|
|
|
}}}
|
|
|
|
|
|
2014-05-12 10:45:25 -04:00
|
|
|
class Dependency : CustomVarObject < DependencyNameComposer
|
2014-02-27 05:05:55 -05:00
|
|
|
{
|
2025-01-10 07:24:27 -05:00
|
|
|
activation_priority -10;
|
|
|
|
|
|
2015-02-25 06:43:03 -05:00
|
|
|
load_after Host;
|
|
|
|
|
load_after Service;
|
|
|
|
|
|
2022-06-20 09:25:40 -04:00
|
|
|
[config, no_user_modify, required, navigation(child_host)] name(Host) child_host_name {
|
2015-09-22 03:42:30 -04:00
|
|
|
navigate {{{
|
|
|
|
|
return Host::GetByName(GetChildHostName());
|
|
|
|
|
}}}
|
|
|
|
|
};
|
|
|
|
|
|
2022-06-20 09:25:40 -04:00
|
|
|
[config, no_user_modify, navigation(child_service)] String child_service_name {
|
2015-08-25 07:53:43 -04:00
|
|
|
track {{{
|
|
|
|
|
if (!oldValue.IsEmpty()) {
|
2021-02-04 12:29:54 -05:00
|
|
|
Service::Ptr service = Service::GetByNamePair(GetChildHostName(), oldValue);
|
2015-08-25 07:53:43 -04:00
|
|
|
DependencyGraph::RemoveDependency(this, service.get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!newValue.IsEmpty()) {
|
2021-02-04 12:29:54 -05:00
|
|
|
Service::Ptr service = Service::GetByNamePair(GetChildHostName(), newValue);
|
2016-05-09 07:48:30 -04:00
|
|
|
DependencyGraph::AddDependency(this, service.get());
|
2015-08-25 07:53:43 -04:00
|
|
|
}
|
|
|
|
|
}}}
|
2015-09-22 03:42:30 -04:00
|
|
|
navigate {{{
|
2026-01-16 12:14:46 -05:00
|
|
|
if (!GetChildServiceName().IsEmpty()) {
|
|
|
|
|
Host::Ptr host = Host::GetByName(GetChildHostName());
|
|
|
|
|
if (host)
|
|
|
|
|
return host->GetServiceByShortName(GetChildServiceName());
|
|
|
|
|
}
|
2015-09-22 03:42:30 -04:00
|
|
|
|
2026-01-16 12:14:46 -05:00
|
|
|
return nullptr;
|
2015-09-22 03:42:30 -04:00
|
|
|
}}}
|
|
|
|
|
};
|
|
|
|
|
|
2022-06-20 09:25:40 -04:00
|
|
|
[config, no_user_modify, required, navigation(parent_host)] name(Host) parent_host_name {
|
2015-09-22 03:42:30 -04:00
|
|
|
navigate {{{
|
|
|
|
|
return Host::GetByName(GetParentHostName());
|
|
|
|
|
}}}
|
2015-08-25 07:53:43 -04:00
|
|
|
};
|
2014-02-27 05:05:55 -05:00
|
|
|
|
2022-06-20 09:25:40 -04:00
|
|
|
[config, no_user_modify, navigation(parent_service)] String parent_service_name {
|
2015-08-25 07:53:43 -04:00
|
|
|
track {{{
|
|
|
|
|
if (!oldValue.IsEmpty()) {
|
|
|
|
|
Service::Ptr service = Service::GetByNamePair(GetParentHostName(), oldValue);
|
|
|
|
|
DependencyGraph::RemoveDependency(this, service.get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!newValue.IsEmpty()) {
|
|
|
|
|
Service::Ptr service = Service::GetByNamePair(GetParentHostName(), newValue);
|
2016-05-09 07:48:30 -04:00
|
|
|
DependencyGraph::AddDependency(this, service.get());
|
2015-08-25 07:53:43 -04:00
|
|
|
}
|
|
|
|
|
}}}
|
2015-09-22 03:42:30 -04:00
|
|
|
navigate {{{
|
2026-01-16 12:14:46 -05:00
|
|
|
if (!GetParentServiceName().IsEmpty()) {
|
|
|
|
|
Host::Ptr host = Host::GetByName(GetParentHostName());
|
|
|
|
|
if (host)
|
|
|
|
|
return host->GetServiceByShortName(GetParentServiceName());
|
|
|
|
|
}
|
2015-09-22 03:42:30 -04:00
|
|
|
|
2026-01-16 12:14:46 -05:00
|
|
|
return nullptr;
|
2015-09-22 03:42:30 -04:00
|
|
|
}}}
|
2015-08-25 07:53:43 -04:00
|
|
|
};
|
2014-02-27 05:05:55 -05:00
|
|
|
|
2024-12-05 03:09:31 -05:00
|
|
|
[config, no_user_modify] String redundancy_group;
|
2020-09-08 11:25:45 -04:00
|
|
|
|
2025-02-17 07:49:39 -05:00
|
|
|
[config, no_user_modify, navigation] name(TimePeriod) period (PeriodRaw) {
|
2015-09-22 03:42:30 -04:00
|
|
|
navigate {{{
|
|
|
|
|
return TimePeriod::GetByName(GetPeriodRaw());
|
|
|
|
|
}}}
|
|
|
|
|
};
|
2014-02-27 05:05:55 -05:00
|
|
|
|
2025-02-17 07:49:39 -05:00
|
|
|
[config, no_user_modify] array(Value) states;
|
2016-07-19 14:09:14 -04:00
|
|
|
[no_user_view, no_user_modify] int state_filter_real (StateFilter);
|
2014-02-27 05:05:55 -05:00
|
|
|
|
2025-02-17 07:49:39 -05:00
|
|
|
[config, no_user_modify] bool ignore_soft_states {
|
2015-02-07 18:30:58 -05:00
|
|
|
default {{{ return true; }}}
|
|
|
|
|
};
|
|
|
|
|
|
2014-02-27 05:05:55 -05:00
|
|
|
[config] bool disable_checks;
|
2014-10-11 13:33:03 -04:00
|
|
|
[config] bool disable_notifications {
|
|
|
|
|
default {{{ return true; }}}
|
|
|
|
|
};
|
2014-02-27 05:05:55 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|