]> granicus.if.org Git - icinga2/commitdiff
Fix: Adding/Removing multiple services fails
authorGunnar Beutner <gunnar.beutner@netways.de>
Sat, 8 Nov 2014 13:57:44 +0000 (14:57 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Sat, 8 Nov 2014 14:17:00 +0000 (15:17 +0100)
fixes #7616

lib/cli/repositoryutility.cpp

index 832849f6a22dbedd1db75d941a17db108f4b2e47..b9c64b91ebf59142362be53fccaea9b74e8c52e3 100644 (file)
@@ -297,6 +297,8 @@ bool RepositoryUtility::SetObjectAttribute(const String& name, const String& typ
 
 bool RepositoryUtility::CheckChangeExists(const Dictionary::Ptr& change)
 {
+       Dictionary::Ptr attrs = change->Get("attrs");
+
        Array::Ptr changelog = make_shared<Array>();
 
        GetChangeLog(boost::bind(RepositoryUtility::CollectChange, _1, changelog));
@@ -309,13 +311,17 @@ bool RepositoryUtility::CheckChangeExists(const Dictionary::Ptr& change)
                if (entry->Get("name") != change->Get("name"))
                        continue;
 
+               Dictionary::Ptr their_attrs = entry->Get("attrs");
+
+               if (entry->Get("type") == "Service" && attrs->Get("host_name") != their_attrs->Get("host_name"))
+                       continue;
+
                if (entry->Get("command") != change->Get("command"))
                        continue;
 
                /* only works for add/remove commands (no set) */
-               if (change->Get("command") == "add" || change->Get("command") == "remove") {
+               if (change->Get("command") == "add" || change->Get("command") == "remove")
                        return true;
-               }
        }
 
        return false;