]> granicus.if.org Git - icinga2/commitdiff
Add CompatUtility::IsLegacyAttribute().
authorMichael Friedrich <michael.friedrich@netways.de>
Fri, 4 Apr 2014 14:35:45 +0000 (16:35 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Fri, 4 Apr 2014 14:35:45 +0000 (16:35 +0200)
Refs #5855

lib/icinga/compatutility.cpp
lib/icinga/compatutility.h

index f18a935e7af10a4e02b42ed8fcbd9343c3f49e01..ffc12d0f15e93df555714125d194f1e198f58020 100644 (file)
@@ -407,6 +407,30 @@ int CompatUtility::GetCheckableInNotificationPeriod(const Checkable::Ptr& checka
 }
 
 /* vars attr */
+
+bool CompatUtility::IsLegacyAttribute(const String& name)
+{
+       if (name == "address" ||
+           name == "address1" ||
+           name == "address2" ||
+           name == "address3" ||
+           name == "address4" ||
+           name == "address5" ||
+           name == "address6" || /* user, host */
+           name == "email" ||
+           name == "pager" ||
+           name == "notes" ||
+           name == "action_url" ||
+           name == "notes_url" ||
+           name == "icon_image" ||
+           name == "icon_image_alt" ||
+           name == "statusmap_image" ||
+           name == "2d_coords")
+               return true;
+
+       return false;
+}
+
 Dictionary::Ptr CompatUtility::GetCustomAttributeConfig(const DynamicObject::Ptr& object)
 {
        ASSERT(object->OwnsLock());
@@ -421,17 +445,7 @@ Dictionary::Ptr CompatUtility::GetCustomAttributeConfig(const DynamicObject::Ptr
        ObjectLock olock(vars);
        BOOST_FOREACH(const Dictionary::Pair& kv, vars) {
                if (!kv.first.IsEmpty()) {
-                       if (kv.first != "address" &&
-                           kv.first != "address6" &&
-                           kv.first != "email" &&
-                           kv.first != "pager" &&
-                           kv.first != "notes" &&
-                           kv.first != "action_url" &&
-                           kv.first != "notes_url" &&
-                           kv.first != "icon_image" &&
-                           kv.first != "icon_image_alt" &&
-                           kv.first != "statusmap_image" &&
-                           kv.first != "2d_coords")
+                       if (!IsLegacyAttribute(kv.first))
                                varsvars->Set(kv.first, kv.second);
                }
        }
index 446a8e9d32d372f7d4f6ff15493fbff3972c413b..936ff58a2a1c163a3b5979870f531d4697975025 100644 (file)
@@ -113,6 +113,7 @@ public:
        static String GetCommandLine(const Command::Ptr& command);
 
        /* custom attribute */
+       static bool IsLegacyAttribute(const String& name);
        static String GetCustomAttributeConfig(const DynamicObject::Ptr& object, const String& name);
        static Dictionary::Ptr GetCustomAttributeConfig(const DynamicObject::Ptr& object);