mirror of https://github.com/Icinga/icinga2.git
Fix missing custom attributes in backends if name is equal to object attribute
fixes #9222
This commit is contained in:
parent
b2eb63c40f
commit
a149b5ae72
|
@ -532,12 +532,7 @@ void StatusDataWriter::DumpCustomAttributes(std::ostream& fp, const CustomVarObj
|
||||||
} else
|
} else
|
||||||
value = kv.second;
|
value = kv.second;
|
||||||
|
|
||||||
fp << "\t";
|
fp << "\t" "_" << kv.first << "\t" << value << "\n";
|
||||||
|
|
||||||
if (!CompatUtility::IsLegacyAttribute(object, kv.first))
|
|
||||||
fp << "_";
|
|
||||||
|
|
||||||
fp << kv.first << "\t" << value << "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_json)
|
if (is_json)
|
||||||
|
|
|
@ -352,58 +352,14 @@ int CompatUtility::GetCheckableInNotificationPeriod(const Checkable::Ptr& checka
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vars attr */
|
/* vars attr */
|
||||||
|
|
||||||
bool CompatUtility::IsLegacyAttribute(const CustomVarObject::Ptr& object, const String& name)
|
|
||||||
{
|
|
||||||
if ((name == "address" ||
|
|
||||||
name == "address6") &&
|
|
||||||
object->GetType() == DynamicType::GetByName("Host"))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if ((name == "address1" ||
|
|
||||||
name == "address2" ||
|
|
||||||
name == "address3" ||
|
|
||||||
name == "address4" ||
|
|
||||||
name == "address5" ||
|
|
||||||
name == "address6" ||
|
|
||||||
name == "email" ||
|
|
||||||
name == "pager") &&
|
|
||||||
object->GetType() == DynamicType::GetByName("User"))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if ((name == "notes" ||
|
|
||||||
name == "action_url" ||
|
|
||||||
name == "notes_url" ||
|
|
||||||
name == "icon_image" ||
|
|
||||||
name == "icon_image_alt") &&
|
|
||||||
(object->GetType() == DynamicType::GetByName("Host") ||
|
|
||||||
object->GetType() == DynamicType::GetByName("Service")))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Dictionary::Ptr CompatUtility::GetCustomAttributeConfig(const CustomVarObject::Ptr& object)
|
Dictionary::Ptr CompatUtility::GetCustomAttributeConfig(const CustomVarObject::Ptr& object)
|
||||||
{
|
{
|
||||||
Dictionary::Ptr vars = object->GetVars();
|
Dictionary::Ptr vars = object->GetVars();
|
||||||
|
|
||||||
Dictionary::Ptr varsvars = new Dictionary();
|
|
||||||
|
|
||||||
if (!vars)
|
if (!vars)
|
||||||
return Dictionary::Ptr();
|
return Dictionary::Ptr();
|
||||||
|
|
||||||
String key;
|
return vars;
|
||||||
Value value;
|
|
||||||
|
|
||||||
ObjectLock olock(vars);
|
|
||||||
BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
|
|
||||||
if (kv.first.IsEmpty() || IsLegacyAttribute(object, kv.first))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
varsvars->Set(kv.first, kv.second);
|
|
||||||
}
|
|
||||||
|
|
||||||
return varsvars;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String CompatUtility::GetCustomAttributeConfig(const CustomVarObject::Ptr& object, const String& name)
|
String CompatUtility::GetCustomAttributeConfig(const CustomVarObject::Ptr& object, const String& name)
|
||||||
|
|
|
@ -103,7 +103,6 @@ public:
|
||||||
static std::set<UserGroup::Ptr> GetCheckableNotificationUserGroups(const Checkable::Ptr& checkable);
|
static std::set<UserGroup::Ptr> GetCheckableNotificationUserGroups(const Checkable::Ptr& checkable);
|
||||||
|
|
||||||
/* custom attribute */
|
/* custom attribute */
|
||||||
static bool IsLegacyAttribute(const CustomVarObject::Ptr& object, const String& name);
|
|
||||||
static String GetCustomAttributeConfig(const CustomVarObject::Ptr& object, const String& name);
|
static String GetCustomAttributeConfig(const CustomVarObject::Ptr& object, const String& name);
|
||||||
static Dictionary::Ptr GetCustomAttributeConfig(const CustomVarObject::Ptr& object);
|
static Dictionary::Ptr GetCustomAttributeConfig(const CustomVarObject::Ptr& object);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue