mirror of
				https://github.com/Icinga/icinga2.git
				synced 2025-10-31 19:24:25 +01:00 
			
		
		
		
	Config: Warn about unknown attributes.
This commit is contained in:
		
							parent
							
								
									e928b1fabf
								
							
						
					
					
						commit
						f5a3dc4d84
					
				| @ -120,6 +120,13 @@ void DynamicObject::InternalApplyUpdate(const Dictionary::Ptr& serializedUpdate, | |||||||
| 		Value data = attr->Get("data"); | 		Value data = attr->Get("data"); | ||||||
| 		double tx = attr->Get("tx"); | 		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) | 		if (type & Attribute_Config) | ||||||
| 			RegisterAttribute(it->first, Attribute_Config); | 			RegisterAttribute(it->first, Attribute_Config); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -111,8 +111,13 @@ void DynamicType::RemoveAttribute(const String& name) | |||||||
| 	m_Attributes.erase(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) | void DynamicType::AddAttributes(const AttributeDescription *attributes, int attributeCount) | ||||||
| { | { | ||||||
| 	for (int i = 0; i < attributeCount; i++) | 	for (int i = 0; i < attributeCount; i++) | ||||||
| 		AddAttribute(attributes[i].Name, attributes[i].Type); | 		AddAttribute(attributes[i].Name, attributes[i].Type); | ||||||
| } | } | ||||||
|  | |||||||
| @ -59,6 +59,7 @@ public: | |||||||
| 
 | 
 | ||||||
| 	void AddAttribute(const String& name, DynamicAttributeType type); | 	void AddAttribute(const String& name, DynamicAttributeType type); | ||||||
| 	void RemoveAttribute(const String& name); | 	void RemoveAttribute(const String& name); | ||||||
|  | 	bool HasAttribute(const String& name); | ||||||
| 
 | 
 | ||||||
| 	void AddAttributes(const AttributeDescription *attributes, int attributeCount); | 	void AddAttributes(const AttributeDescription *attributes, int attributeCount); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -29,6 +29,8 @@ static AttributeDescription hostAttributes[] = { | |||||||
| 	{ "hostgroups", Attribute_Config }, | 	{ "hostgroups", Attribute_Config }, | ||||||
| 	{ "dependencies", Attribute_Config }, | 	{ "dependencies", Attribute_Config }, | ||||||
| 	{ "hostchecks", Attribute_Config }, | 	{ "hostchecks", Attribute_Config }, | ||||||
|  | 	{ "macros", Attribute_Config }, | ||||||
|  | 	{ "services", Attribute_Config }, | ||||||
| 	{ "acknowledgement", Attribute_Replicated }, | 	{ "acknowledgement", Attribute_Replicated }, | ||||||
| 	{ "acknowledgement_expiry", Attribute_Replicated }, | 	{ "acknowledgement_expiry", Attribute_Replicated }, | ||||||
| 	{ "downtimes", Attribute_Replicated }, | 	{ "downtimes", Attribute_Replicated }, | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user