1 /******************************************************************************
3 * Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/) *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License *
7 * as published by the Free Software Foundation; either version 2 *
8 * of the License, or (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software Foundation *
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ******************************************************************************/
20 #include "base/configobject.hpp"
21 #include "base/utility.hpp"
22 #impl_include "icinga/service.hpp"
30 class DowntimeNameComposer : public NameComposer
33 virtual String MakeName(const String& shortName, const Object::Ptr& context) const;
34 virtual Dictionary::Ptr ParseName(const String& name) const;
38 class Downtime : ConfigObject < DowntimeNameComposer
43 [config, protected, required, navigation(host)] name(Host) host_name {
45 return Host::GetByName(GetHostName());
48 [config, protected, navigation(service)] String service_name {
50 if (!oldValue.IsEmpty()) {
51 Service::Ptr service = Service::GetByNamePair(GetHostName(), oldValue);
52 DependencyGraph::RemoveDependency(this, service.get());
55 if (!newValue.IsEmpty()) {
56 Service::Ptr service = Service::GetByNamePair(GetHostName(), newValue);
57 DependencyGraph::AddDependency(this, service.get());
61 if (GetServiceName().IsEmpty())
64 Host::Ptr host = Host::GetByName(GetHostName());
65 return host->GetServiceByShortName(GetServiceName());
69 [config] Timestamp entry_time {
70 default {{{ return Utility::GetTime(); }}}
72 [config, required] String author;
73 [config, required] String comment;
74 [config] Timestamp start_time;
75 [config] Timestamp end_time;
76 [state] Timestamp trigger_time;
78 [config] Timestamp duration;
79 [config] String triggered_by;
80 [config] String scheduled_by;
81 [state] Array::Ptr triggers {
82 default {{{ return new Array(); }}}
84 [state] int legacy_id;
85 [state] bool was_cancelled;
86 [config] String config_owner;