]> granicus.if.org Git - icinga2/commitdiff
Fix missing custom attributes in backends if name is equal to object attribute
authorMichael Friedrich <michael.friedrich@netways.de>
Fri, 15 May 2015 13:59:02 +0000 (15:59 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Fri, 15 May 2015 13:59:44 +0000 (15:59 +0200)
fixes #9222

lib/compat/statusdatawriter.cpp
lib/icinga/compatutility.cpp
lib/icinga/compatutility.hpp

index e5e5f24ba38920edcaa4d043a8ad6c56868a512a..a28e1ceb50c40d376315982e0d65cc25daa0a9f3 100644 (file)
@@ -533,12 +533,7 @@ void StatusDataWriter::DumpCustomAttributes(std::ostream& fp, const CustomVarObj
                } else
                        value = kv.second;
 
-               fp << "\t";
-
-               if (!CompatUtility::IsLegacyAttribute(object, kv.first))
-                       fp << "_";
-
-               fp << kv.first << "\t" << value << "\n";
+               fp << "\t" "_" << kv.first << "\t" << value << "\n";
        }
 
        if (is_json)
index 688560110975f52fb6e7b8e5778c84524cf58f48..d2cbd863015d2500225313f8a74c96f366c13e3d 100644 (file)
@@ -352,58 +352,14 @@ int CompatUtility::GetCheckableInNotificationPeriod(const Checkable::Ptr& checka
 }
 
 /* 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 vars = object->GetVars();
 
-       Dictionary::Ptr varsvars = new Dictionary();
-
        if (!vars)
                return Dictionary::Ptr();
 
-       String key;
-       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;
+       return vars;
 }
 
 String CompatUtility::GetCustomAttributeConfig(const CustomVarObject::Ptr& object, const String& name)
index 669c5fe105acf10870e11b04a0de8191dcc38226..edba4b9f94e145ce6bb71185273ff0866fe2c314 100644 (file)
@@ -103,7 +103,6 @@ public:
        static std::set<UserGroup::Ptr> GetCheckableNotificationUserGroups(const Checkable::Ptr& checkable);
 
        /* custom attribute */
-       static bool IsLegacyAttribute(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);