Config: Warn about unknown attributes.

This commit is contained in:
Gunnar Beutner 2013-02-01 14:11:22 +01:00
parent e928b1fabf
commit f5a3dc4d84
4 changed files with 16 additions and 1 deletions

View File

@ -120,6 +120,13 @@ void DynamicObject::InternalApplyUpdate(const Dictionary::Ptr& serializedUpdate,
Value data = attr->Get("data");
double tx = attr->Get("tx");
if (!HasAttribute(it->first)) {
DynamicType::Ptr dtype = GetType();
if (dtype && !dtype->HasAttribute(it->first))
Logger::Write(LogWarning, "base", "Adding unknown attribute '" +
it->first + "' to object '" + GetName() + "' of type '" + dtype->GetName() + "'");
}
if (type & Attribute_Config)
RegisterAttribute(it->first, Attribute_Config);

View File

@ -111,6 +111,11 @@ void DynamicType::RemoveAttribute(const String& name)
m_Attributes.erase(name);
}
bool DynamicType::HasAttribute(const String& name)
{
return (m_Attributes.find(name) != m_Attributes.end());
}
void DynamicType::AddAttributes(const AttributeDescription *attributes, int attributeCount)
{
for (int i = 0; i < attributeCount; i++)

View File

@ -59,6 +59,7 @@ public:
void AddAttribute(const String& name, DynamicAttributeType type);
void RemoveAttribute(const String& name);
bool HasAttribute(const String& name);
void AddAttributes(const AttributeDescription *attributes, int attributeCount);

View File

@ -29,6 +29,8 @@ static AttributeDescription hostAttributes[] = {
{ "hostgroups", Attribute_Config },
{ "dependencies", Attribute_Config },
{ "hostchecks", Attribute_Config },
{ "macros", Attribute_Config },
{ "services", Attribute_Config },
{ "acknowledgement", Attribute_Replicated },
{ "acknowledgement_expiry", Attribute_Replicated },
{ "downtimes", Attribute_Replicated },