Update validator for services dictionary.

This commit is contained in:
Gunnar Beutner 2013-03-08 14:44:03 +01:00
parent fb82b73bc9
commit 4668e458ce
1 changed files with 21 additions and 16 deletions

View File

@ -387,21 +387,25 @@ void Host::ValidateServiceDictionary(const ScriptTask::Ptr& task, const vector<V
String key;
Value value;
BOOST_FOREACH(tie(key, value), attrs) {
String name;
vector<String> templates;
if (value.IsScalar()) {
name = value;
templates.push_back(value);
} else if (value.IsObjectType<Dictionary>()) {
Dictionary::Ptr serviceDesc = value;
name = serviceDesc->Get("service");
Dictionary::Ptr templatesDict = serviceDesc->Get("templates");
ObjectLock tlock(templatesDict);
if (name.IsEmpty())
name = key;
Value tmpl;
BOOST_FOREACH(tie(tuples::ignore, tmpl), templatesDict) {
templates.push_back(tmpl);
}
} else {
continue;
}
BOOST_FOREACH(const String& name, templates) {
ConfigItem::Ptr item;
ConfigCompilerContext *context = ConfigCompilerContext::GetContext();
@ -416,7 +420,8 @@ void Host::ValidateServiceDictionary(const ScriptTask::Ptr& task, const vector<V
if (!item) {
ConfigCompilerContext::GetContext()->AddError(false, "Validation failed for " +
location + ": Service '" + name + "' not found.");
location + ": Template '" + name + "' not found.");
}
}
}