2019-02-25 08:48:22 -05:00
|
|
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
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:
|
2014-11-06 13:35:47 -05:00
|
|
|
virtual String MakeName(const String& shortName, const Object::Ptr& context) const;
|
2015-08-13 03:02:52 -04:00
|
|
|
virtual Dictionary::Ptr ParseName(const String& name) const;
|
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
|
|
|
{
|
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 {{{
|
|
|
|
|
if (GetChildServiceName().IsEmpty())
|
2017-11-30 02:36:35 -05:00
|
|
|
return nullptr;
|
2015-09-22 03:42:30 -04:00
|
|
|
|
|
|
|
|
Host::Ptr host = Host::GetByName(GetChildHostName());
|
|
|
|
|
return host->GetServiceByShortName(GetChildServiceName());
|
|
|
|
|
}}}
|
|
|
|
|
};
|
|
|
|
|
|
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 {{{
|
|
|
|
|
if (GetParentServiceName().IsEmpty())
|
2017-11-30 02:36:35 -05:00
|
|
|
return nullptr;
|
2015-09-22 03:42:30 -04:00
|
|
|
|
|
|
|
|
Host::Ptr host = Host::GetByName(GetParentHostName());
|
|
|
|
|
return host->GetServiceByShortName(GetParentServiceName());
|
|
|
|
|
}}}
|
2015-08-25 07:53:43 -04:00
|
|
|
};
|
2014-02-27 05:05:55 -05:00
|
|
|
|
2015-09-22 03:42:30 -04:00
|
|
|
[config, navigation] name(TimePeriod) period (PeriodRaw) {
|
|
|
|
|
navigate {{{
|
|
|
|
|
return TimePeriod::GetByName(GetPeriodRaw());
|
|
|
|
|
}}}
|
|
|
|
|
};
|
2014-02-27 05:05:55 -05:00
|
|
|
|
2016-06-24 08:17:24 -04:00
|
|
|
[config] 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
|
|
|
|
2015-02-07 18:30:58 -05:00
|
|
|
[config] bool ignore_soft_states {
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|