]> granicus.if.org Git - icinga2/commitdiff
Cli: Fix 'repository host remove' for hosts w/o services
authorMichael Friedrich <michael.friedrich@netways.de>
Tue, 28 Oct 2014 14:23:51 +0000 (15:23 +0100)
committerMichael Friedrich <michael.friedrich@netways.de>
Tue, 28 Oct 2014 14:27:17 +0000 (15:27 +0100)
refs #7255

lib/cli/repositoryutility.cpp

index 88936266fc54e94d4cbd150f403d28bbe7c73f13..109ef4dfe0b06eefffdbb609a546c3ac0f6865f4 100644 (file)
@@ -350,10 +350,19 @@ bool RepositoryUtility::RemoveObjectInternal(const String& name, const String& t
        if (type == "Host") {
                path = GetRepositoryObjectConfigPath(type, attrs) + "/" + name;
 
+               /* if path does not exist, this host does not have any services */
+               if (!Utility::PathExists(path)) {
+                       Log(LogNotice, "cli")
+                           << type << " '" << name << "' does not have any services configured.";
+                       return success;
+               }
+
                std::vector<String> files;
+
                Utility::GlobRecursive(path, "*.conf",
                    boost::bind(&RepositoryUtility::CollectObjects, _1, boost::ref(files)), GlobFile);
 
+
                BOOST_FOREACH(const String& file, files) {
                        RemoveObjectFileInternal(file);
                }