2014-10-17 19:44:31 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* Icinga 2 *
|
2018-10-18 09:30:00 +02:00
|
|
|
* Copyright (C) 2012-2018 Icinga Development Team (https://icinga.com/) *
|
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 21:19:52 +01:00
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
|
|
|
code {{{
|
|
|
|
/**
|
|
|
|
* The type of a service comment.
|
|
|
|
*
|
|
|
|
* @ingroup icinga
|
|
|
|
*/
|
|
|
|
enum CommentType
|
|
|
|
{
|
|
|
|
CommentUser = 1,
|
|
|
|
CommentDowntime = 2,
|
|
|
|
CommentFlapping = 3,
|
|
|
|
CommentAcknowledgement = 4
|
|
|
|
};
|
2015-08-20 17:18:48 +02:00
|
|
|
|
2017-12-31 07:22:16 +01:00
|
|
|
class CommentNameComposer : public NameComposer
|
2015-08-20 17:18:48 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual String MakeName(const String& shortName, const Object::Ptr& context) const;
|
|
|
|
virtual Dictionary::Ptr ParseName(const String& name) const;
|
|
|
|
};
|
2013-11-09 21:19:52 +01:00
|
|
|
}}}
|
|
|
|
|
2015-08-20 17:18:48 +02:00
|
|
|
class Comment : ConfigObject < CommentNameComposer
|
2013-11-09 21:19:52 +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())
|
2017-11-30 08:36:35 +01:00
|
|
|
return nullptr;
|
2015-08-20 17:18:48 +02:00
|
|
|
|
|
|
|
Host::Ptr host = Host::GetByName(GetHostName());
|
|
|
|
return host->GetServiceByShortName(GetServiceName());
|
|
|
|
}}}
|
|
|
|
};
|
|
|
|
|
2016-06-21 11:29:12 +02:00
|
|
|
[config] Timestamp entry_time {
|
2015-08-20 17:18:48 +02:00
|
|
|
default {{{ return Utility::GetTime(); }}}
|
|
|
|
};
|
|
|
|
[config, enum] CommentType entry_type {
|
|
|
|
default {{{ return CommentUser; }}}
|
|
|
|
};
|
|
|
|
[config, required] String author;
|
|
|
|
[config, required] String text;
|
2017-01-25 21:21:22 +01:00
|
|
|
[config] bool persistent;
|
2016-06-21 11:29:12 +02:00
|
|
|
[config] Timestamp expire_time;
|
2016-03-23 14:03:44 +01:00
|
|
|
[state] int legacy_id;
|
2013-11-09 21:19:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|