mirror of https://github.com/Icinga/icinga2.git
parent
53c0ea1b9e
commit
816d0e8d73
|
@ -48,7 +48,7 @@ ConfigItem::ItemMap ConfigItem::m_Items;
|
|||
ConfigItem::ConfigItem(const String& type, const String& name,
|
||||
bool abstract, const ExpressionList::Ptr& exprl,
|
||||
const std::vector<String>& parents, const DebugInfo& debuginfo)
|
||||
: m_Type(type), m_Name(name), m_Abstract(abstract),
|
||||
: m_Type(type), m_Name(name), m_Abstract(abstract), m_Validated(false),
|
||||
m_ExpressionList(exprl), m_ParentNames(parents), m_DebugInfo(debuginfo)
|
||||
{
|
||||
}
|
||||
|
@ -235,6 +235,9 @@ ConfigItem::Ptr ConfigItem::GetObject(const String& type, const String& name)
|
|||
|
||||
void ConfigItem::ValidateItem(void)
|
||||
{
|
||||
if (m_Validated)
|
||||
return;
|
||||
|
||||
ConfigType::Ptr ctype = ConfigType::GetByName(GetType());
|
||||
|
||||
if (!ctype) {
|
||||
|
@ -244,6 +247,8 @@ void ConfigItem::ValidateItem(void)
|
|||
}
|
||||
|
||||
ctype->ValidateItem(GetSelf());
|
||||
|
||||
m_Validated = true;
|
||||
}
|
||||
|
||||
bool ConfigItem::ActivateItems(bool validateOnly)
|
||||
|
@ -258,6 +263,15 @@ bool ConfigItem::ActivateItems(bool validateOnly)
|
|||
item->Link();
|
||||
}
|
||||
|
||||
if (ConfigCompilerContext::GetInstance()->HasErrors())
|
||||
return false;
|
||||
|
||||
Log(LogInformation, "config", "Validating config items (step 1)...");
|
||||
|
||||
BOOST_FOREACH(boost::tie(boost::tuples::ignore, item), m_Items) {
|
||||
item->ValidateItem();
|
||||
}
|
||||
|
||||
if (ConfigCompilerContext::GetInstance()->HasErrors())
|
||||
return false;
|
||||
|
||||
|
@ -276,6 +290,8 @@ bool ConfigItem::ActivateItems(bool validateOnly)
|
|||
object->OnConfigLoaded();
|
||||
}
|
||||
|
||||
Log(LogInformation, "config", "Validating config items (step 2)...");
|
||||
|
||||
BOOST_FOREACH(boost::tie(boost::tuples::ignore, item), m_Items) {
|
||||
item->ValidateItem();
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ private:
|
|||
String m_Type; /**< The object type. */
|
||||
String m_Name; /**< The name. */
|
||||
bool m_Abstract; /**< Whether this is a template. */
|
||||
bool m_Validated; /** Whether this object has been validated. */
|
||||
|
||||
ExpressionList::Ptr m_ExpressionList;
|
||||
std::vector<String> m_ParentNames; /**< The names of parent configuration
|
||||
|
|
Loading…
Reference in New Issue