Cli: Make sure to check for removed nodes only once in 'node update-config'

fixes #7917
This commit is contained in:
Michael Friedrich 2014-12-10 18:48:35 +01:00
parent 0f496c0b55
commit eb4de1884c

View File

@ -88,7 +88,7 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm
std::vector<String> object_paths = RepositoryUtility::GetObjects();
bool creation_error = false;
/* first make sure that all nodes are valid and should not be removed */
BOOST_FOREACH(const Dictionary::Ptr& node, NodeUtility::GetNodes()) {
Dictionary::Ptr repository = node->Get("repository");
String zone = node->Get("zone");
@ -97,6 +97,7 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm
/* store existing structure in index */
inventory->Set(endpoint, node);
}
if (old_inventory) {
/* check if there are objects inside the old_inventory which do not exist anymore */
@ -199,6 +200,13 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm
}
}
/* next iterate over all nodes and add hosts/services */
BOOST_FOREACH(const Dictionary::Ptr& node, NodeUtility::GetNodes()) {
Dictionary::Ptr repository = node->Get("repository");
String zone = node->Get("zone");
String endpoint = node->Get("endpoint");
String node_name = endpoint;
Dictionary::Ptr host_services = new Dictionary();
Log(LogInformation, "cli")
@ -215,7 +223,6 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm
if (!RepositoryUtility::AddObject(zone, "Host", host_attrs)) {
Log(LogCritical, "cli")
<< "Cannot add node host '" << zone << "' to the config repository!\n";
creation_error = true;
}
if (repository) {
@ -356,7 +363,6 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm
if (!RepositoryUtility::AddObject(endpoint, "Endpoint", endpoint_attrs)) {
Log(LogCritical, "cli")
<< "Cannot add node endpoint '" << endpoint << "' to the config repository!\n";
creation_error = true;
}
Dictionary::Ptr zone_attrs = new Dictionary();
@ -392,7 +398,6 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm
if (!RepositoryUtility::AddObject(zone, "Zone", zone_attrs)) {
Log(LogCritical, "cli")
<< "Cannot add node zone '" << zone << "' to the config repository!\n";
creation_error = true;
}
}