1 /******************************************************************************
3 * Copyright (C) 2012-2018 Icinga Development Team (https://icinga.com/) *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License *
7 * as published by the Free Software Foundation; either version 2 *
8 * of the License, or (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software Foundation *
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ******************************************************************************/
20 #include "cli/apisetupcommand.hpp"
21 #include "cli/apisetuputility.hpp"
22 #include "cli/variableutility.hpp"
23 #include "base/logger.hpp"
24 #include "base/console.hpp"
27 using namespace icinga;
28 namespace po = boost::program_options;
30 REGISTER_CLICOMMAND("api/setup", ApiSetupCommand);
32 String ApiSetupCommand::GetDescription() const
34 return "Setup for Icinga 2 API.";
37 String ApiSetupCommand::GetShortDescription() const
39 return "setup for API";
42 ImpersonationLevel ApiSetupCommand::GetImpersonationLevel() const
44 return ImpersonateRoot;
47 int ApiSetupCommand::GetMaxArguments() const
53 * The entry point for the "api setup" CLI command.
55 * @returns An exit status.
57 int ApiSetupCommand::Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const
59 String cn = VariableUtility::GetVariable("NodeName");
62 cn = Utility::GetFQDN();
64 if (!ApiSetupUtility::SetupMaster(cn, true))