]> granicus.if.org Git - icinga2/commitdiff
Implement support for removing more than one agent
authorGunnar Beutner <gunnar@beutner.name>
Fri, 24 Oct 2014 10:16:14 +0000 (12:16 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Fri, 24 Oct 2014 10:18:24 +0000 (12:18 +0200)
refs #7248

lib/cli/agentremovecommand.cpp

index b6014626bf7b0d87b2cceca1ff5e0e2a7fd2ce09..ddc3dc69897bb31dc2bd3c9624187608868541cc 100644 (file)
@@ -60,10 +60,17 @@ int AgentRemoveCommand::Run(const boost::program_options::variables_map& vm, con
                return 1;
        }
 
-       if (!AgentUtility::RemoveAgent(ap[0])) {
-               Log(LogCritical, "cli", "Cannot remove agent '" + ap[0] + "'.");
-               return 1;
+       bool failed = false;
+
+       BOOST_FOREACH(const String& agent, ap) {
+               if (!AgentUtility::RemoveAgent(agent)) {
+                       Log(LogCritical, "cli", "Cannot remove agent '" + ap[0] + "'.");
+                       failed = true;
+               }
        }
 
-       return 0;
+       if (failed)
+               return 1;
+       else
+               return 0;
 }