]> granicus.if.org Git - icinga2/commitdiff
Use the correct zone name for parent_zone when running 'icinga2 node update-config'
authorGunnar Beutner <gunnar@beutner.name>
Thu, 29 Oct 2015 07:07:02 +0000 (08:07 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Thu, 29 Oct 2015 07:14:55 +0000 (08:14 +0100)
fixes #10479

lib/cli/nodeupdateconfigcommand.cpp
lib/icinga/clusterevents.cpp

index b90cf20126cb301510ce560554ba912dd105e443..449aa28fc474c762f045363149396d91a8154283 100644 (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);
index e90f5e5532236a2b4aa79f81822b7b803e5ad3fa..27990c8005e926aef3ab5be6ee7f222a7727aa0f 100644 (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);