#include "icinga/checkable.hpp"
#include "icinga/checkable.tcpp"
+#include "icinga/host.hpp"
+#include "icinga/service.hpp"
#include "base/objectlock.hpp"
#include "base/utility.hpp"
#include "base/exception.hpp"
{
boost::mutex::scoped_lock lock(m_CheckableMutex);
- Array::Ptr groups = GetGroups();
+ Array::Ptr groups;
+ Host *host = dynamic_cast<Host *>(this);
+
+ if (host)
+ groups = host->GetGroups();
+ else
+ groups = static_cast<Service *>(this)->GetGroups();
if (groups && groups->Contains(name))
return;
abstract class Checkable : CustomVarObject
{
- [config] Array::Ptr groups {
- default {{{ return new Array(); }}}
- };
[config, protected, required] name(CheckCommand) check_command (CheckCommandRaw);
[config] int max_check_attempts (MaxCheckAttemptsRaw) {
default {{{ return 3; }}}
if (validatorType != ValidatorField)
m_Impl << "const String& key, ";
- bool static_known_attribute = false;
-
m_Impl << fieldType.GetArgumentType() << " value, std::vector<String>& location, const ValidationUtils& utils)" << std::endl
<< "{" << std::endl;
if (validatorType == ValidatorField) {
- static_known_attribute = true;
-
bool required = false;
for (std::vector<Rule>::size_type i = 0; i < rules.size(); i++) {
}
}
- if (!static_known_attribute)
+ if (validatorType != ValidatorField)
m_Impl << "\t" << "bool known_attribute = false;" << std::endl;
bool type_check = false;
m_Impl << "\t\t" << "if (key != \"" << rule.Pattern << "\")" << std::endl;
m_Impl << "\t\t\t" << "break;" << std::endl;
- } else
- static_known_attribute = true;
+ }
- if (!static_known_attribute)
- m_Impl << "\t\t" << "known_attribute = true;" << std::endl;
+ m_Impl << "\t\t" << "known_attribute = true;" << std::endl;
}
if (rule.IsName) {
}
if (type_check || validatorType != ValidatorField) {
- if (!static_known_attribute)
+ if (validatorType != ValidatorField) {
m_Impl << "\t" << "if (!known_attribute)" << std::endl
<< "\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_pointer_cast<DynamicObject>(object), location, \"Invalid attribute: \" + key));" << std::endl
<< "\t" << "else" << std::endl;
+ }
- m_Impl << (!static_known_attribute ? "\t" : "") << "\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_pointer_cast<DynamicObject>(object), location, \"Invalid type.\"));" << std::endl;
+ m_Impl << (validatorType != ValidatorField ? "\t" : "") << "\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_pointer_cast<DynamicObject>(object), location, \"Invalid type.\"));" << std::endl;
}
m_Impl << "}" << std::endl << std::endl;