From: Gunnar Beutner Date: Thu, 26 Nov 2015 07:09:24 +0000 (+0100) Subject: Use the NodeName constant in 'api setup' X-Git-Tag: v2.5.0~696 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7f9337eee81a2f63c5af67cc2108cbf52e5ec305;p=icinga2 Use the NodeName constant in 'api setup' fixes #10641 --- diff --git a/lib/cli/apisetupcommand.cpp b/lib/cli/apisetupcommand.cpp index 562a44d64..8d6aa35fe 100644 --- a/lib/cli/apisetupcommand.cpp +++ b/lib/cli/apisetupcommand.cpp @@ -19,6 +19,7 @@ #include "cli/apisetupcommand.hpp" #include "cli/apisetuputility.hpp" +#include "cli/variableutility.hpp" #include "base/logger.hpp" #include "base/console.hpp" #include @@ -55,7 +56,12 @@ int ApiSetupCommand::GetMaxArguments(void) const */ int ApiSetupCommand::Run(const boost::program_options::variables_map& vm, const std::vector& ap) const { - if (!ApiSetupUtility::SetupMaster(Utility::GetFQDN(), true)) + String cn = VariableUtility::GetVariable("NodeName"); + + if (cn.IsEmpty()) + cn = Utility::GetFQDN(); + + if (!ApiSetupUtility::SetupMaster(cn, true)) return 1; return 0;