From: Michael Friedrich Date: Tue, 28 Oct 2014 14:23:51 +0000 (+0100) Subject: Cli: Fix 'repository host remove' for hosts w/o services X-Git-Tag: v2.2.0~217 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ab5a55d754cee85642c8ed5a91d79dbf6f699b99;p=icinga2 Cli: Fix 'repository host remove' for hosts w/o services refs #7255 --- diff --git a/lib/cli/repositoryutility.cpp b/lib/cli/repositoryutility.cpp index 88936266f..109ef4dfe 100644 --- a/lib/cli/repositoryutility.cpp +++ b/lib/cli/repositoryutility.cpp @@ -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 files; + Utility::GlobRecursive(path, "*.conf", boost::bind(&RepositoryUtility::CollectObjects, _1, boost::ref(files)), GlobFile); + BOOST_FOREACH(const String& file, files) { RemoveObjectFileInternal(file); }