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 7library icinga; 8 9namespace icinga 10{ 11 12code {{{ 13class DowntimeNameComposer : public NameComposer 14{ 15public: 16 virtual String MakeName(const String& shortName, const Object::Ptr& context) const; 17 virtual Dictionary::Ptr ParseName(const String& name) const; 18}; 19}}} 20 21class 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 [config] String parent; 67 [state] Array::Ptr triggers { 68 default {{{ return new Array(); }}} 69 }; 70 [state] int legacy_id; 71 [state] bool was_cancelled; 72 [config] String config_owner; 73 [config] String config_owner_hash; 74 [config] String authoritative_zone; 75 76 [no_user_view, no_user_modify] String removed_by; 77}; 78 79} 80