mirror of https://github.com/Icinga/icinga2.git
Fix legacy attributes by object type.
This commit is contained in:
parent
d64823858d
commit
34092f0a52
|
@ -518,7 +518,7 @@ void StatusDataWriter::DumpCustomAttributes(std::ostream& fp, const DynamicObjec
|
||||||
if (!kv.first.IsEmpty()) {
|
if (!kv.first.IsEmpty()) {
|
||||||
fp << "\t";
|
fp << "\t";
|
||||||
|
|
||||||
if (!CompatUtility::IsLegacyAttribute(kv.first))
|
if (!CompatUtility::IsLegacyAttribute(object, kv.first))
|
||||||
fp << "_";
|
fp << "_";
|
||||||
|
|
||||||
fp << kv.first << "\t" << kv.second << "\n";
|
fp << kv.first << "\t" << kv.second << "\n";
|
||||||
|
|
|
@ -408,24 +408,33 @@ int CompatUtility::GetCheckableInNotificationPeriod(const Checkable::Ptr& checka
|
||||||
|
|
||||||
/* vars attr */
|
/* vars attr */
|
||||||
|
|
||||||
bool CompatUtility::IsLegacyAttribute(const String& name)
|
bool CompatUtility::IsLegacyAttribute(DynamicObject::Ptr const& object, const String& name)
|
||||||
{
|
{
|
||||||
if (name == "address" ||
|
if ((name == "address" ||
|
||||||
name == "address1" ||
|
name == "address6" ||
|
||||||
|
name == "statusmap_image" ||
|
||||||
|
name == "2d_coords") &&
|
||||||
|
object->GetType() == DynamicType::GetByName("Host"))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if ((name == "address1" ||
|
||||||
name == "address2" ||
|
name == "address2" ||
|
||||||
name == "address3" ||
|
name == "address3" ||
|
||||||
name == "address4" ||
|
name == "address4" ||
|
||||||
name == "address5" ||
|
name == "address5" ||
|
||||||
name == "address6" || /* user, host */
|
name == "address6" ||
|
||||||
name == "email" ||
|
name == "email" ||
|
||||||
name == "pager" ||
|
name == "pager") &&
|
||||||
name == "notes" ||
|
object->GetType() == DynamicType::GetByName("User"))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if ((name == "notes" ||
|
||||||
name == "action_url" ||
|
name == "action_url" ||
|
||||||
name == "notes_url" ||
|
name == "notes_url" ||
|
||||||
name == "icon_image" ||
|
name == "icon_image" ||
|
||||||
name == "icon_image_alt" ||
|
name == "icon_image_alt") &&
|
||||||
name == "statusmap_image" ||
|
(object->GetType() == DynamicType::GetByName("Host") ||
|
||||||
name == "2d_coords")
|
object->GetType() == DynamicType::GetByName("Service")))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -445,7 +454,7 @@ Dictionary::Ptr CompatUtility::GetCustomAttributeConfig(const DynamicObject::Ptr
|
||||||
ObjectLock olock(vars);
|
ObjectLock olock(vars);
|
||||||
BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
|
BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
|
||||||
if (!kv.first.IsEmpty()) {
|
if (!kv.first.IsEmpty()) {
|
||||||
if (!IsLegacyAttribute(kv.first))
|
if (!IsLegacyAttribute(object, kv.first))
|
||||||
varsvars->Set(kv.first, kv.second);
|
varsvars->Set(kv.first, kv.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ public:
|
||||||
static String GetCommandLine(const Command::Ptr& command);
|
static String GetCommandLine(const Command::Ptr& command);
|
||||||
|
|
||||||
/* custom attribute */
|
/* custom attribute */
|
||||||
static bool IsLegacyAttribute(const String& name);
|
static bool IsLegacyAttribute(const DynamicObject::Ptr& object, const String& name);
|
||||||
static String GetCustomAttributeConfig(const DynamicObject::Ptr& object, const String& name);
|
static String GetCustomAttributeConfig(const DynamicObject::Ptr& object, const String& name);
|
||||||
static Dictionary::Ptr GetCustomAttributeConfig(const DynamicObject::Ptr& object);
|
static Dictionary::Ptr GetCustomAttributeConfig(const DynamicObject::Ptr& object);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue