]> granicus.if.org Git - icinga2/blob - lib/icinga/downtime.ti
Merge pull request #7527 from Icinga/bugfix/checkable-command-endpoint-zone
[icinga2] / lib / icinga / downtime.ti
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
3 #include "base/configobject.hpp"
4 #include "base/utility.hpp"
5 #impl_include "icinga/service.hpp"
6
7 library icinga;
8
9 namespace icinga
10 {
11
12 code {{{
13 class DowntimeNameComposer : 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 Downtime : ConfigObject < DowntimeNameComposer
22 {
23         activation_priority -10;
24
25         load_after Host;
26         load_after Service;
27
28         [config, protected, required, navigation(host)] name(Host) host_name {
29                 navigate {{{
30                         return Host::GetByName(GetHostName());
31                 }}}
32         };
33         [config, protected, navigation(service)] String service_name {
34                 track {{{
35                         if (!oldValue.IsEmpty()) {
36                                 Service::Ptr service = Service::GetByNamePair(GetHostName(), oldValue);
37                                 DependencyGraph::RemoveDependency(this, service.get());
38                         }
39
40                         if (!newValue.IsEmpty()) {
41                                 Service::Ptr service = Service::GetByNamePair(GetHostName(), newValue);
42                                 DependencyGraph::AddDependency(this, service.get());
43                         }
44                 }}}
45                 navigate {{{
46                         if (GetServiceName().IsEmpty())
47                                 return nullptr;
48
49                         Host::Ptr host = Host::GetByName(GetHostName());
50                         return host->GetServiceByShortName(GetServiceName());
51                 }}}
52         };
53
54         [config] Timestamp entry_time {
55                 default {{{ return Utility::GetTime(); }}}
56         };
57         [config, required] String author;
58         [config, required] String comment;
59         [config] Timestamp start_time;
60         [config] Timestamp end_time;
61         [state] Timestamp trigger_time;
62         [config] bool fixed;
63         [config] Timestamp duration;
64         [config] String triggered_by;
65         [config] String scheduled_by;
66         [state] Array::Ptr triggers {
67                 default {{{ return new Array(); }}}
68         };
69         [state] int legacy_id;
70         [state] bool was_cancelled;
71         [config] String config_owner;
72         [config] String authoritative_zone;
73 };
74
75 }