Use the correct zone name for parent_zone when running 'icinga2 node update-config'

fixes #10479
This commit is contained in:
Gunnar Beutner 2015-10-29 08:07:02 +01:00
parent 0013d26425
commit 15addb4e7c
2 changed files with 5 additions and 18 deletions

View File

@ -20,6 +20,7 @@
#include "cli/nodeupdateconfigcommand.hpp"
#include "cli/nodeutility.hpp"
#include "cli/repositoryutility.hpp"
#include "cli/variableutility.hpp"
#include "base/logger.hpp"
#include "base/console.hpp"
#include "base/application.hpp"
@ -387,21 +388,12 @@ int NodeUpdateConfigCommand::Run(const boost::program_options::variables_map& vm
zone_attrs->Set("name", zone);
zone_attrs->Set("endpoints", zone_members);
String node_parent_zone = "master"; //hardcode the name
String parent_zone;
String parent_zone = VariableUtility::GetVariable("ZoneName");
if (!node->Contains("parent_zone")) {
if (parent_zone.IsEmpty()) {
Log(LogWarning, "cli")
<< "Node '" << endpoint << "' does not have any parent zone defined. Using 'master' as default. Please verify the generated configuration.";
parent_zone = node_parent_zone;
} else {
parent_zone = node->Get("parent_zone");
if (parent_zone.IsEmpty()) {
Log(LogWarning, "cli")
<< "Node '" << endpoint << "' does not have any parent zone defined. Using 'master' as default. Please verify the generated configuration.";
parent_zone = node_parent_zone;
}
<< "Variable 'ZoneName' is not set. Falling back to using 'master' as default. Please verify the generated configuration.";
parent_zone = "master";
}
zone_attrs->Set("parent", parent_zone);

View File

@ -695,11 +695,6 @@ void ClusterEvents::RepositoryTimerHandler(void)
Dictionary::Ptr params = new Dictionary();
params->Set("seen", Utility::GetTime());
params->Set("endpoint", my_endpoint->GetName());
Zone::Ptr parent_zone = my_zone->GetParent();
if (parent_zone)
params->Set("parent_zone", parent_zone->GetName());
params->Set("zone", my_zone->GetName());
params->Set("repository", repository);