]> granicus.if.org Git - icinga2/blob - lib/icinga/dependency.ti
Merge pull request #7527 from Icinga/bugfix/checkable-command-endpoint-zone
[icinga2] / lib / icinga / dependency.ti
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
3 #include "icinga/customvarobject.hpp"
4 #include "icinga/checkable.hpp"
5 #impl_include "icinga/service.hpp"
6
7 library icinga;
8
9 namespace icinga
10 {
11
12 code {{{
13 class DependencyNameComposer : public NameComposer
14 {
15 public:
16         virtual String MakeName(const String& shortName, const Object::Ptr& context) const;
17         virtual Dictionary::Ptr ParseName(const String& name) const;
18 };
19 }}}
20
21 class Dependency : CustomVarObject < DependencyNameComposer
22 {
23         load_after Host;
24         load_after Service;
25
26         [config, required, navigation(child_host)] name(Host) child_host_name {
27                 navigate {{{
28                         return Host::GetByName(GetChildHostName());
29                 }}}
30         };
31
32         [config, navigation(child_service)] String child_service_name {
33                 track {{{
34                         if (!oldValue.IsEmpty()) {
35                                 Service::Ptr service = Service::GetByNamePair(GetParentHostName(), oldValue);
36                                 DependencyGraph::RemoveDependency(this, service.get());
37                         }
38
39                         if (!newValue.IsEmpty()) {
40                                 Service::Ptr service = Service::GetByNamePair(GetParentHostName(), newValue);
41                                 DependencyGraph::AddDependency(this, service.get());
42                         }
43                 }}}
44                 navigate {{{
45                         if (GetChildServiceName().IsEmpty())
46                                 return nullptr;
47
48                         Host::Ptr host = Host::GetByName(GetChildHostName());
49                         return host->GetServiceByShortName(GetChildServiceName());
50                 }}}
51         };
52
53         [config, required, navigation(parent_host)] name(Host) parent_host_name {
54                 navigate {{{
55                         return Host::GetByName(GetParentHostName());
56                 }}}
57         };
58
59         [config, navigation(parent_service)] String parent_service_name {
60                 track {{{
61                         if (!oldValue.IsEmpty()) {
62                                 Service::Ptr service = Service::GetByNamePair(GetParentHostName(), oldValue);
63                                 DependencyGraph::RemoveDependency(this, service.get());
64                         }
65
66                         if (!newValue.IsEmpty()) {
67                                 Service::Ptr service = Service::GetByNamePair(GetParentHostName(), newValue);
68                                 DependencyGraph::AddDependency(this, service.get());
69                         }
70                 }}}
71                 navigate {{{
72                         if (GetParentServiceName().IsEmpty())
73                                 return nullptr;
74
75                         Host::Ptr host = Host::GetByName(GetParentHostName());
76                         return host->GetServiceByShortName(GetParentServiceName());
77                 }}}
78         };
79
80         [config, navigation] name(TimePeriod) period (PeriodRaw) {
81                 navigate {{{
82                         return TimePeriod::GetByName(GetPeriodRaw());
83                 }}}
84         };
85
86         [config] array(Value) states;
87         [no_user_view, no_user_modify] int state_filter_real (StateFilter);
88
89         [config] bool ignore_soft_states {
90                 default {{{ return true; }}}
91         };
92
93         [config] bool disable_checks;
94         [config] bool disable_notifications {
95                 default {{{ return true; }}}
96         };
97 };
98
99 }