2014-10-17 19:44:31 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
2016-01-12 08:29:59 +01:00
|
|
|
* Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/) *
|
2014-10-17 19:44:31 +02:00
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License *
|
|
|
|
* as published by the Free Software Foundation; either version 2 *
|
|
|
|
* of the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program; if not, write to the Free Software Foundation *
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
|
|
|
******************************************************************************/
|
|
|
|
|
2015-08-20 17:18:48 +02:00
|
|
|
#include "base/configobject.hpp"
|
|
|
|
#include "base/utility.hpp"
|
|
|
|
#impl_include "icinga/service.hpp"
|
|
|
|
|
2015-08-04 14:47:44 +02:00
|
|
|
library icinga;
|
|
|
|
|
2013-11-09 22:08:26 +01:00
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
2015-08-20 17:18:48 +02:00
|
|
|
code {{{
|
|
|
|
class I2_ICINGA_API DowntimeNameComposer : public NameComposer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual String MakeName(const String& shortName, const Object::Ptr& context) const;
|
|
|
|
virtual Dictionary::Ptr ParseName(const String& name) const;
|
|
|
|
};
|
|
|
|
}}}
|
|
|
|
|
|
|
|
class Downtime : ConfigObject < DowntimeNameComposer
|
2013-11-09 22:08:26 +01:00
|
|
|
{
|
2015-08-20 17:18:48 +02:00
|
|
|
load_after Host;
|
|
|
|
load_after Service;
|
|
|
|
|
|
|
|
[config, protected, required, navigation(host)] name(Host) host_name {
|
|
|
|
navigate {{{
|
|
|
|
return Host::GetByName(GetHostName());
|
|
|
|
}}}
|
|
|
|
};
|
|
|
|
[config, protected, navigation(service)] String service_name {
|
|
|
|
track {{{
|
|
|
|
if (!oldValue.IsEmpty()) {
|
|
|
|
Service::Ptr service = Service::GetByNamePair(GetHostName(), oldValue);
|
|
|
|
DependencyGraph::RemoveDependency(this, service.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!newValue.IsEmpty()) {
|
|
|
|
Service::Ptr service = Service::GetByNamePair(GetHostName(), newValue);
|
2016-05-09 13:48:30 +02:00
|
|
|
DependencyGraph::AddDependency(this, service.get());
|
2015-08-20 17:18:48 +02:00
|
|
|
}
|
|
|
|
}}}
|
|
|
|
navigate {{{
|
|
|
|
if (GetServiceName().IsEmpty())
|
|
|
|
return Service::Ptr();
|
|
|
|
|
|
|
|
Host::Ptr host = Host::GetByName(GetHostName());
|
|
|
|
return host->GetServiceByShortName(GetServiceName());
|
|
|
|
}}}
|
|
|
|
};
|
|
|
|
|
2016-06-15 11:28:20 +02:00
|
|
|
[config] double entry_time {
|
2015-08-20 17:18:48 +02:00
|
|
|
default {{{ return Utility::GetTime(); }}}
|
|
|
|
};
|
|
|
|
[config, required] String author;
|
|
|
|
[config, required] String comment;
|
|
|
|
[config] double start_time;
|
|
|
|
[config] double end_time;
|
2013-11-09 22:08:26 +01:00
|
|
|
[state] double trigger_time;
|
2015-08-20 17:18:48 +02:00
|
|
|
[config] bool fixed;
|
|
|
|
[config] double duration;
|
2015-11-12 09:31:27 +01:00
|
|
|
[config] name(Downtime) triggered_by;
|
2015-08-20 17:18:48 +02:00
|
|
|
[config] String scheduled_by;
|
2015-11-12 09:31:27 +01:00
|
|
|
[state] Array::Ptr triggers {
|
2015-08-20 17:18:48 +02:00
|
|
|
default {{{ return new Array(); }}}
|
2013-11-09 22:08:26 +01:00
|
|
|
};
|
2016-03-23 14:03:44 +01:00
|
|
|
[state] int legacy_id;
|
2013-11-09 22:08:26 +01:00
|
|
|
[state] bool was_cancelled;
|
2015-08-20 17:18:48 +02:00
|
|
|
[config] String config_owner;
|
2013-11-09 22:08:26 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|