From f9209ec5e8f88a4fe9b4004eeebdc7b374ae9531 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Fri, 17 Oct 2014 15:13:17 +0200 Subject: [PATCH] Cli commands: Add basic agent command set refs #7248 --- lib/cli/CMakeLists.txt | 2 + lib/cli/agentaddcommand.cpp | 62 +++++++++++ lib/cli/agentaddcommand.hpp | 46 ++++++++ lib/cli/agentblackandwhitelistcommand.cpp | 124 ++++++++++++++++++++++ lib/cli/agentblackandwhitelistcommand.hpp | 77 ++++++++++++++ lib/cli/agentlistcommand.cpp | 59 ++++++++++ lib/cli/agentlistcommand.hpp | 46 ++++++++ lib/cli/agentremovecommand.cpp | 62 +++++++++++ lib/cli/agentremovecommand.hpp | 46 ++++++++ lib/cli/agentsetcommand.cpp | 70 ++++++++++++ lib/cli/agentsetcommand.hpp | 48 +++++++++ lib/cli/agentsetupcommand.cpp | 68 ++++++++++++ lib/cli/agentsetupcommand.hpp | 48 +++++++++ lib/cli/agentupdateconfigcommand.cpp | 59 ++++++++++ lib/cli/agentupdateconfigcommand.hpp | 46 ++++++++ lib/cli/agentutility.cpp | 43 ++++++++ lib/cli/agentutility.hpp | 45 ++++++++ lib/cli/agentwizardcommand.cpp | 59 ++++++++++ lib/cli/agentwizardcommand.hpp | 46 ++++++++ 19 files changed, 1056 insertions(+) create mode 100644 lib/cli/agentaddcommand.cpp create mode 100644 lib/cli/agentaddcommand.hpp create mode 100644 lib/cli/agentblackandwhitelistcommand.cpp create mode 100644 lib/cli/agentblackandwhitelistcommand.hpp create mode 100644 lib/cli/agentlistcommand.cpp create mode 100644 lib/cli/agentlistcommand.hpp create mode 100644 lib/cli/agentremovecommand.cpp create mode 100644 lib/cli/agentremovecommand.hpp create mode 100644 lib/cli/agentsetcommand.cpp create mode 100644 lib/cli/agentsetcommand.hpp create mode 100644 lib/cli/agentsetupcommand.cpp create mode 100644 lib/cli/agentsetupcommand.hpp create mode 100644 lib/cli/agentupdateconfigcommand.cpp create mode 100644 lib/cli/agentupdateconfigcommand.hpp create mode 100644 lib/cli/agentutility.cpp create mode 100644 lib/cli/agentutility.hpp create mode 100644 lib/cli/agentwizardcommand.cpp create mode 100644 lib/cli/agentwizardcommand.hpp diff --git a/lib/cli/CMakeLists.txt b/lib/cli/CMakeLists.txt index c369c50ca..aed5ce951 100644 --- a/lib/cli/CMakeLists.txt +++ b/lib/cli/CMakeLists.txt @@ -16,6 +16,8 @@ # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. set(cli_SOURCES + agentaddcommand.cpp agentblackandwhitelistcommand.cpp agentlistcommand.cpp agentremovecommand.cpp + agentsetcommand.cpp agentsetupcommand.cpp agentupdateconfigcommand.cpp agentwizardcommand.cpp agentutility.cpp featureenablecommand.cpp featuredisablecommand.cpp featurelistcommand.cpp objectlistcommand.cpp pkinewcacommand.cpp pkinewcertcommand.cpp pkisigncsrcommand.cpp pkirequestcommand.cpp pkiticketcommand.cpp diff --git a/lib/cli/agentaddcommand.cpp b/lib/cli/agentaddcommand.cpp new file mode 100644 index 000000000..75623033c --- /dev/null +++ b/lib/cli/agentaddcommand.cpp @@ -0,0 +1,62 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#include "cli/agentaddcommand.hpp" +#include "base/logger_fwd.hpp" +#include "base/clicommand.hpp" +#include "base/application.hpp" +#include +#include +#include +#include +#include +#include +#include + +using namespace icinga; +namespace po = boost::program_options; + +REGISTER_CLICOMMAND("agent/add", AgentAddCommand); + +String AgentAddCommand::GetDescription(void) const +{ + return "Add Icinga 2 agent."; +} + +String AgentAddCommand::GetShortDescription(void) const +{ + return "add agent"; +} + +/** + * The entry point for the "agent add" CLI command. + * + * @returns An exit status. + */ +int AgentAddCommand::Run(const boost::program_options::variables_map& vm, const std::vector& ap) const +{ + if (ap.empty()) { + Log(LogCritical, "cli", "No agent name provided."); + return 1; + } + + //ap[0] must contain name + + return 0; +} diff --git a/lib/cli/agentaddcommand.hpp b/lib/cli/agentaddcommand.hpp new file mode 100644 index 000000000..2202034db --- /dev/null +++ b/lib/cli/agentaddcommand.hpp @@ -0,0 +1,46 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#ifndef AGENTADDCOMMAND_H +#define AGENTADDCOMMAND_H + +#include "base/qstring.hpp" +#include "base/clicommand.hpp" + +namespace icinga +{ + +/** + * The "agent add" command. + * + * @ingroup cli + */ +class AgentAddCommand : public CLICommand +{ +public: + DECLARE_PTR_TYPEDEFS(AgentAddCommand); + + virtual String GetDescription(void) const; + virtual String GetShortDescription(void) const; + virtual int Run(const boost::program_options::variables_map& vm, const std::vector& ap) const; +}; + +} + +#endif /* AGENTADDCOMMAND_H */ diff --git a/lib/cli/agentblackandwhitelistcommand.cpp b/lib/cli/agentblackandwhitelistcommand.cpp new file mode 100644 index 000000000..dcc2c54dc --- /dev/null +++ b/lib/cli/agentblackandwhitelistcommand.cpp @@ -0,0 +1,124 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#include "cli/agentblackandwhitelistcommand.hpp" +#include "base/logger_fwd.hpp" +#include "base/clicommand.hpp" +#include "base/application.hpp" +#include "base/tlsutility.hpp" +#include +#include + +using namespace icinga; + +REGISTER_BLACKANDWHITELIST_CLICOMMAND("whitelist"); +REGISTER_BLACKANDWHITELIST_CLICOMMAND("blacklist"); + +RegisterBlackAndWhitelistCLICommandHelper::RegisterBlackAndWhitelistCLICommandHelper(const String& type) +{ + String ltype = type; + boost::algorithm::to_lower(ltype); + + std::vector name; + name.push_back("agent"); + name.push_back(ltype); + name.push_back("add"); + CLICommand::Register(name, make_shared(type, BlackAndWhitelistCommandAdd)); + + name[2] = "remove"; + CLICommand::Register(name, make_shared(type, BlackAndWhitelistCommandRemove)); + + name[2] = "list"; + CLICommand::Register(name, make_shared(type, BlackAndWhitelistCommandList)); +} + +BlackAndWhitelistCommand::BlackAndWhitelistCommand(const String& type, BlackAndWhitelistCommandType command) + : m_Type(type), m_Command(command) +{ } + +String BlackAndWhitelistCommand::GetDescription(void) const +{ + String description; + + switch (m_Command) { + case BlackAndWhitelistCommandAdd: + description = "Adds a new"; + break; + case BlackAndWhitelistCommandRemove: + description = "Removes a"; + break; + case BlackAndWhitelistCommandList: + description = "Lists all"; + break; + } + + description += " " + m_Type + " filter"; + + if (m_Command == BlackAndWhitelistCommandList) + description += "s"; + + return description; +} + +String BlackAndWhitelistCommand::GetShortDescription(void) const +{ + String description; + + switch (m_Command) { + case BlackAndWhitelistCommandAdd: + description = "adds a new"; + break; + case BlackAndWhitelistCommandRemove: + description = "removes a"; + break; + case BlackAndWhitelistCommandList: + description = "lists all"; + break; + } + + description += " " + m_Type + " filter"; + + if (m_Command == BlackAndWhitelistCommandList) + description += "s"; + + return description; +} + +void BlackAndWhitelistCommand::InitParameters(boost::program_options::options_description& visibleDesc, + boost::program_options::options_description& hiddenDesc) const +{ + visibleDesc.add_options() + ("agent", po::value(), "The name of the agent") + ("host", po::value(), "The name of the host") + ("service", po::value(), "The name of the service"); + + if (m_Command == BlackAndWhitelistCommandAdd) { + //TODO: call list functionality + } +} + +/** + * The entry point for the "agent " CLI command. + * + * @returns An exit status. + */ +int BlackAndWhitelistCommand::Run(const boost::program_options::variables_map& vm, const std::vector& ap) const +{ + return 0; +} diff --git a/lib/cli/agentblackandwhitelistcommand.hpp b/lib/cli/agentblackandwhitelistcommand.hpp new file mode 100644 index 000000000..a019a0050 --- /dev/null +++ b/lib/cli/agentblackandwhitelistcommand.hpp @@ -0,0 +1,77 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#ifndef BLACKANDWHITELISTCOMMAND_H +#define BLACKANDWHITELISTCOMMAND_H + +#include "base/qstring.hpp" +#include "base/clicommand.hpp" + +namespace icinga +{ + +enum BlackAndWhitelistCommandType +{ + BlackAndWhitelistCommandAdd, + BlackAndWhitelistCommandRemove, + BlackAndWhitelistCommandList +}; + +/** + * The "repository " command. + * + * @ingroup cli + */ +class BlackAndWhitelistCommand : public CLICommand +{ +public: + DECLARE_PTR_TYPEDEFS(BlackAndWhitelistCommand); + + BlackAndWhitelistCommand(const String& type, BlackAndWhitelistCommandType command); + + virtual String GetDescription(void) const; + virtual String GetShortDescription(void) const; + virtual void InitParameters(boost::program_options::options_description& visibleDesc, + boost::program_options::options_description& hiddenDesc) const; + virtual int Run(const boost::program_options::variables_map& vm, const std::vector& ap) const; + +private: + String m_Type; + BlackAndWhitelistCommandType m_Command; +}; + +/** + * Helper class for registering repository CLICommand implementation classes. + * + * @ingroup cli + */ +class I2_BASE_API RegisterBlackAndWhitelistCLICommandHelper +{ +public: + RegisterBlackAndWhitelistCLICommandHelper(const String& type); +}; + +#define REGISTER_BLACKANDWHITELIST_CLICOMMAND(type) \ + namespace { namespace UNIQUE_NAME(cli) { \ + I2_EXPORT icinga::RegisterBlackAndWhitelistCLICommandHelper l_RegisterBlackAndWhitelistCLICommand(type); \ + } } + +} + +#endif /* BLACKANDWHITELISTCOMMAND_H */ diff --git a/lib/cli/agentlistcommand.cpp b/lib/cli/agentlistcommand.cpp new file mode 100644 index 000000000..c309fc37a --- /dev/null +++ b/lib/cli/agentlistcommand.cpp @@ -0,0 +1,59 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#include "cli/agentlistcommand.hpp" +#include "base/logger_fwd.hpp" +#include "base/clicommand.hpp" +#include "base/application.hpp" +#include +#include +#include +#include +#include +#include +#include + +using namespace icinga; +namespace po = boost::program_options; + +REGISTER_CLICOMMAND("agent/list", AgentListCommand); + +String AgentListCommand::GetDescription(void) const +{ + return "Lists all Icinga 2 agents."; +} + +String AgentListCommand::GetShortDescription(void) const +{ + return "lists all agents"; +} + +/** + * The entry point for the "agent list" CLI command. + * + * @returns An exit status. + */ +int AgentListCommand::Run(const boost::program_options::variables_map& vm, const std::vector& ap) const +{ + if (!ap.empty()) { + Log(LogWarning, "cli", "Ignoring parameters: " + boost::algorithm::join(ap, " ")); + } + + return 0; +} diff --git a/lib/cli/agentlistcommand.hpp b/lib/cli/agentlistcommand.hpp new file mode 100644 index 000000000..650d741f0 --- /dev/null +++ b/lib/cli/agentlistcommand.hpp @@ -0,0 +1,46 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#ifndef AGENTLISTCOMMAND_H +#define AGENTLISTCOMMAND_H + +#include "base/qstring.hpp" +#include "base/clicommand.hpp" + +namespace icinga +{ + +/** + * The "pki new-ca" command. + * + * @ingroup cli + */ +class AgentListCommand : public CLICommand +{ +public: + DECLARE_PTR_TYPEDEFS(AgentListCommand); + + virtual String GetDescription(void) const; + virtual String GetShortDescription(void) const; + virtual int Run(const boost::program_options::variables_map& vm, const std::vector& ap) const; +}; + +} + +#endif /* AGENTLISTCOMMAND_H */ diff --git a/lib/cli/agentremovecommand.cpp b/lib/cli/agentremovecommand.cpp new file mode 100644 index 000000000..68569f12a --- /dev/null +++ b/lib/cli/agentremovecommand.cpp @@ -0,0 +1,62 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#include "cli/agentremovecommand.hpp" +#include "base/logger_fwd.hpp" +#include "base/clicommand.hpp" +#include "base/application.hpp" +#include +#include +#include +#include +#include +#include +#include + +using namespace icinga; +namespace po = boost::program_options; + +REGISTER_CLICOMMAND("agent/remove", AgentRemoveCommand); + +String AgentRemoveCommand::GetDescription(void) const +{ + return "Remove Icinga 2 agent."; +} + +String AgentRemoveCommand::GetShortDescription(void) const +{ + return "remove agent"; +} + +/** + * The entry point for the "agent remove" CLI command. + * + * @returns An exit status. + */ +int AgentRemoveCommand::Run(const boost::program_options::variables_map& vm, const std::vector& ap) const +{ + if (ap.empty()) { + Log(LogCritical, "cli", "No agent name provided."); + return 1; + } + + //ap[0] must contain name + + return 0; +} diff --git a/lib/cli/agentremovecommand.hpp b/lib/cli/agentremovecommand.hpp new file mode 100644 index 000000000..f400b7e8b --- /dev/null +++ b/lib/cli/agentremovecommand.hpp @@ -0,0 +1,46 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#ifndef AGENTREMOVECOMMAND_H +#define AGENTREMOVECOMMAND_H + +#include "base/qstring.hpp" +#include "base/clicommand.hpp" + +namespace icinga +{ + +/** + * The "agent remove" command. + * + * @ingroup cli + */ +class AgentRemoveCommand : public CLICommand +{ +public: + DECLARE_PTR_TYPEDEFS(AgentRemoveCommand); + + virtual String GetDescription(void) const; + virtual String GetShortDescription(void) const; + virtual int Run(const boost::program_options::variables_map& vm, const std::vector& ap) const; +}; + +} + +#endif /* AGENTREMOVECOMMAND_H */ diff --git a/lib/cli/agentsetcommand.cpp b/lib/cli/agentsetcommand.cpp new file mode 100644 index 000000000..275287f57 --- /dev/null +++ b/lib/cli/agentsetcommand.cpp @@ -0,0 +1,70 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#include "cli/agentsetcommand.hpp" +#include "base/logger_fwd.hpp" +#include "base/clicommand.hpp" +#include "base/application.hpp" +#include +#include +#include +#include +#include +#include +#include + +using namespace icinga; +namespace po = boost::program_options; + +REGISTER_CLICOMMAND("agent/set", AgentSetCommand); + +String AgentSetCommand::GetDescription(void) const +{ + return "Lists all Icinga 2 agents."; +} + +String AgentSetCommand::GetShortDescription(void) const +{ + return "lists all agents"; +} + +void AgentSetCommand::InitParameters(boost::program_options::options_description& visibleDesc, + boost::program_options::options_description& hiddenDesc) const +{ + /* Command doesn't support any parameters. */ +} + +/** + * The entry point for the "agent set" CLI command. + * + * @returns An exit status. + */ +int AgentSetCommand::Run(const boost::program_options::variables_map& vm, const std::vector& ap) const +{ + if (ap.empty()) { + Log(LogCritical, "cli", "No agent name provided."); + return 1; + } + + //ap[0] must contain name + //ap[1] must contain attr + //ap[2] must contain val + + return 0; +} diff --git a/lib/cli/agentsetcommand.hpp b/lib/cli/agentsetcommand.hpp new file mode 100644 index 000000000..274ff4e7c --- /dev/null +++ b/lib/cli/agentsetcommand.hpp @@ -0,0 +1,48 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#ifndef AGENTSETCOMMAND_H +#define AGENTSETCOMMAND_H + +#include "base/qstring.hpp" +#include "base/clicommand.hpp" + +namespace icinga +{ + +/** + * The "agent set" command. + * + * @ingroup cli + */ +class AgentSetCommand : public CLICommand +{ +public: + DECLARE_PTR_TYPEDEFS(AgentSetCommand); + + virtual String GetDescription(void) const; + virtual String GetShortDescription(void) const; + virtual void InitParameters(boost::program_options::options_description& visibleDesc, + boost::program_options::options_description& hiddenDesc) const; + virtual int Run(const boost::program_options::variables_map& vm, const std::vector& ap) const; +}; + +} + +#endif /* AGENTSETCOMMAND_H */ diff --git a/lib/cli/agentsetupcommand.cpp b/lib/cli/agentsetupcommand.cpp new file mode 100644 index 000000000..7da0fc1e3 --- /dev/null +++ b/lib/cli/agentsetupcommand.cpp @@ -0,0 +1,68 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#include "cli/agentsetupcommand.hpp" +#include "base/logger_fwd.hpp" +#include "base/clicommand.hpp" +#include "base/application.hpp" +#include +#include +#include +#include +#include +#include +#include + +using namespace icinga; +namespace po = boost::program_options; + +REGISTER_CLICOMMAND("agent/setup", AgentSetupCommand); + +String AgentSetupCommand::GetDescription(void) const +{ + return "Sets up an Icinga 2 agent."; +} + +String AgentSetupCommand::GetShortDescription(void) const +{ + return "set up agent"; +} + +void AgentSetupCommand::InitParameters(boost::program_options::options_description& visibleDesc, + boost::program_options::options_description& hiddenDesc) const +{ + visibleDesc.add_options() + ("master", po::value(), "The name of the Icinga 2 master") + ("master_zone", po::value(), "The name of the master zone") + ("listen", po::value(), "Listen on host:port"); +} + +/** + * The entry point for the "agent setup" CLI command. + * + * @returns An exit status. + */ +int AgentSetupCommand::Run(const boost::program_options::variables_map& vm, const std::vector& ap) const +{ + if (!ap.empty()) { + Log(LogWarning, "cli", "Ignoring parameters: " + boost::algorithm::join(ap, " ")); + } + + return 0; +} diff --git a/lib/cli/agentsetupcommand.hpp b/lib/cli/agentsetupcommand.hpp new file mode 100644 index 000000000..2b27e62b1 --- /dev/null +++ b/lib/cli/agentsetupcommand.hpp @@ -0,0 +1,48 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#ifndef AGENTSETUPCOMMAND_H +#define AGENTSETUPCOMMAND_H + +#include "base/qstring.hpp" +#include "base/clicommand.hpp" + +namespace icinga +{ + +/** + * The "agent setup" command. + * + * @ingroup cli + */ +class AgentSetupCommand : public CLICommand +{ +public: + DECLARE_PTR_TYPEDEFS(AgentSetupCommand); + + virtual String GetDescription(void) const; + virtual String GetShortDescription(void) const; + virtual void InitParameters(boost::program_options::options_description& visibleDesc, + boost::program_options::options_description& hiddenDesc) const; + virtual int Run(const boost::program_options::variables_map& vm, const std::vector& ap) const; +}; + +} + +#endif /* AGENTSETUPCOMMAND_H */ diff --git a/lib/cli/agentupdateconfigcommand.cpp b/lib/cli/agentupdateconfigcommand.cpp new file mode 100644 index 000000000..0e5af159d --- /dev/null +++ b/lib/cli/agentupdateconfigcommand.cpp @@ -0,0 +1,59 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#include "cli/agentupdateconfigcommand.hpp" +#include "base/logger_fwd.hpp" +#include "base/clicommand.hpp" +#include "base/application.hpp" +#include +#include +#include +#include +#include +#include +#include + +using namespace icinga; +namespace po = boost::program_options; + +REGISTER_CLICOMMAND("agent/update-config", AgentUpdateConfigCommand); + +String AgentUpdateConfigCommand::GetDescription(void) const +{ + return "Update Icinga 2 agent config."; +} + +String AgentUpdateConfigCommand::GetShortDescription(void) const +{ + return "update agent config"; +} + +/** + * The entry point for the "agetn update-config" CLI command. + * + * @returns An exit status. + */ +int AgentUpdateConfigCommand::Run(const boost::program_options::variables_map& vm, const std::vector& ap) const +{ + if (!ap.empty()) { + Log(LogWarning, "cli", "Ignoring parameters: " + boost::algorithm::join(ap, " ")); + } + + return 0; +} diff --git a/lib/cli/agentupdateconfigcommand.hpp b/lib/cli/agentupdateconfigcommand.hpp new file mode 100644 index 000000000..9ca6a9327 --- /dev/null +++ b/lib/cli/agentupdateconfigcommand.hpp @@ -0,0 +1,46 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#ifndef AGENTUPDATECONFIGCOMMAND_H +#define AGENTUPDATECONFIGCOMMAND_H + +#include "base/qstring.hpp" +#include "base/clicommand.hpp" + +namespace icinga +{ + +/** + * The "agent update-config" command. + * + * @ingroup cli + */ +class AgentUpdateConfigCommand : public CLICommand +{ +public: + DECLARE_PTR_TYPEDEFS(AgentUpdateConfigCommand); + + virtual String GetDescription(void) const; + virtual String GetShortDescription(void) const; + virtual int Run(const boost::program_options::variables_map& vm, const std::vector& ap) const; +}; + +} + +#endif /* AGENTUPDATECONFIGCOMMAND_H */ diff --git a/lib/cli/agentutility.cpp b/lib/cli/agentutility.cpp new file mode 100644 index 000000000..a05e08cb9 --- /dev/null +++ b/lib/cli/agentutility.cpp @@ -0,0 +1,43 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#include "cli/agentutility.hpp" + + +using namespace icinga; + +void AgentUtility::ListAgents(void) +{ + +} + +bool AgentUtility::AddAgent(const String& name) +{ + return true; +} + +bool AgentUtility::RemoveAgent(const String& name) +{ + return true; +} + +bool AgentUtility::SetAgentAttribute(const String& attr, const Value& val) +{ + return true; +} diff --git a/lib/cli/agentutility.hpp b/lib/cli/agentutility.hpp new file mode 100644 index 000000000..981e3020a --- /dev/null +++ b/lib/cli/agentutility.hpp @@ -0,0 +1,45 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#ifndef AGENTUTILITYCOMMAND_H +#define AGENTUTILITYCOMMAND_H + +namespace icinga +{ + +/** + * The "pki new-ca" command. + * + * @ingroup cli + */ +class AgentUtility { + +public: + DECLARE_PTR_TYPEDEFS(AgentUtility); + + void ListAgents(void); + bool AddAgent(const String& name); + bool RemoveAgent(const String& name); + bool SetAgentAttribute(const String& attr, const Value& val); + +}; + +} + +#endif /* AGENTUTILITYCOMMAND_H */ diff --git a/lib/cli/agentwizardcommand.cpp b/lib/cli/agentwizardcommand.cpp new file mode 100644 index 000000000..17db4a2db --- /dev/null +++ b/lib/cli/agentwizardcommand.cpp @@ -0,0 +1,59 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#include "cli/agentwizardcommand.hpp" +#include "base/logger_fwd.hpp" +#include "base/clicommand.hpp" +#include "base/application.hpp" +#include +#include +#include +#include +#include +#include +#include + +using namespace icinga; +namespace po = boost::program_options; + +REGISTER_CLICOMMAND("agent/wizard", AgentWizardCommand); + +String AgentWizardCommand::GetDescription(void) const +{ + return "Wizard for Icinga 2 agent setup."; +} + +String AgentWizardCommand::GetShortDescription(void) const +{ + return "wizard for agent setup"; +} + +/** + * The entry point for the "agent wizard" CLI command. + * + * @returns An exit status. + */ +int AgentWizardCommand::Run(const boost::program_options::variables_map& vm, const std::vector& ap) const +{ + if (!ap.empty()) { + Log(LogWarning, "cli", "Ignoring parameters: " + boost::algorithm::join(ap, " ")); + } + + return 0; +} diff --git a/lib/cli/agentwizardcommand.hpp b/lib/cli/agentwizardcommand.hpp new file mode 100644 index 000000000..e9be2d0ca --- /dev/null +++ b/lib/cli/agentwizardcommand.hpp @@ -0,0 +1,46 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012-2014 Icinga Development Team (http://www.icinga.org) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#ifndef AGENTWIZARDCOMMAND_H +#define AGENTWIZARDCOMMAND_H + +#include "base/qstring.hpp" +#include "base/clicommand.hpp" + +namespace icinga +{ + +/** + * The "agent wizard" command. + * + * @ingroup cli + */ +class AgentWizardCommand : public CLICommand +{ +public: + DECLARE_PTR_TYPEDEFS(AgentWizardCommand); + + virtual String GetDescription(void) const; + virtual String GetShortDescription(void) const; + virtual int Run(const boost::program_options::variables_map& vm, const std::vector& ap) const; +}; + +} + +#endif /* AGENTWIZARDCOMMAND_H */