]> granicus.if.org Git - icinga2/commitdiff
Cli commands: Add basic agent command set
authorMichael Friedrich <michael.friedrich@netways.de>
Fri, 17 Oct 2014 13:13:17 +0000 (15:13 +0200)
committerMichael Friedrich <michael.friedrich@netways.de>
Fri, 17 Oct 2014 14:06:12 +0000 (16:06 +0200)
refs #7248

19 files changed:
lib/cli/CMakeLists.txt
lib/cli/agentaddcommand.cpp [new file with mode: 0644]
lib/cli/agentaddcommand.hpp [new file with mode: 0644]
lib/cli/agentblackandwhitelistcommand.cpp [new file with mode: 0644]
lib/cli/agentblackandwhitelistcommand.hpp [new file with mode: 0644]
lib/cli/agentlistcommand.cpp [new file with mode: 0644]
lib/cli/agentlistcommand.hpp [new file with mode: 0644]
lib/cli/agentremovecommand.cpp [new file with mode: 0644]
lib/cli/agentremovecommand.hpp [new file with mode: 0644]
lib/cli/agentsetcommand.cpp [new file with mode: 0644]
lib/cli/agentsetcommand.hpp [new file with mode: 0644]
lib/cli/agentsetupcommand.cpp [new file with mode: 0644]
lib/cli/agentsetupcommand.hpp [new file with mode: 0644]
lib/cli/agentupdateconfigcommand.cpp [new file with mode: 0644]
lib/cli/agentupdateconfigcommand.hpp [new file with mode: 0644]
lib/cli/agentutility.cpp [new file with mode: 0644]
lib/cli/agentutility.hpp [new file with mode: 0644]
lib/cli/agentwizardcommand.cpp [new file with mode: 0644]
lib/cli/agentwizardcommand.hpp [new file with mode: 0644]

index c369c50ca9440d40aba0938391404348e52305c5..aed5ce951c7e4566c55d33fa3f04cf679d27a157 100644 (file)
@@ -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 (file)
index 0000000..7562303
--- /dev/null
@@ -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 <boost/foreach.hpp>
+#include <boost/algorithm/string/join.hpp>
+#include <boost/algorithm/string/replace.hpp>
+#include <fstream>
+#include <vector>
+#include <string>
+#include <unistd.h>
+
+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<std::string>& 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 (file)
index 0000000..2202034
--- /dev/null
@@ -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<std::string>& ap) const;
+};
+
+}
+
+#endif /* AGENTADDCOMMAND_H */
diff --git a/lib/cli/agentblackandwhitelistcommand.cpp b/lib/cli/agentblackandwhitelistcommand.cpp
new file mode 100644 (file)
index 0000000..dcc2c54
--- /dev/null
@@ -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 <boost/algorithm/string/case_conv.hpp>
+#include <fstream>
+
+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<String> name;
+       name.push_back("agent");
+       name.push_back(ltype);
+       name.push_back("add");
+       CLICommand::Register(name, make_shared<BlackAndWhitelistCommand>(type, BlackAndWhitelistCommandAdd));
+
+       name[2] = "remove";
+       CLICommand::Register(name, make_shared<BlackAndWhitelistCommand>(type, BlackAndWhitelistCommandRemove));
+
+       name[2] = "list";
+       CLICommand::Register(name, make_shared<BlackAndWhitelistCommand>(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<std::string>(), "The name of the agent")
+               ("host", po::value<std::string>(), "The name of the host")
+               ("service", po::value<std::string>(), "The name of the service");
+
+       if (m_Command == BlackAndWhitelistCommandAdd) {
+               //TODO: call list functionality
+       }
+}
+
+/**
+ * The entry point for the "agent <whitelist/blacklist> <add/remove/list>" CLI command.
+ *
+ * @returns An exit status.
+ */
+int BlackAndWhitelistCommand::Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const
+{
+       return 0;
+}
diff --git a/lib/cli/agentblackandwhitelistcommand.hpp b/lib/cli/agentblackandwhitelistcommand.hpp
new file mode 100644 (file)
index 0000000..a019a00
--- /dev/null
@@ -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 <type> <add/remove/list>" 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<std::string>& 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 (file)
index 0000000..c309fc3
--- /dev/null
@@ -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 <boost/foreach.hpp>
+#include <boost/algorithm/string/join.hpp>
+#include <boost/algorithm/string/replace.hpp>
+#include <fstream>
+#include <vector>
+#include <string>
+#include <unistd.h>
+
+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<std::string>& 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 (file)
index 0000000..650d741
--- /dev/null
@@ -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<std::string>& ap) const;
+};
+
+}
+
+#endif /* AGENTLISTCOMMAND_H */
diff --git a/lib/cli/agentremovecommand.cpp b/lib/cli/agentremovecommand.cpp
new file mode 100644 (file)
index 0000000..68569f1
--- /dev/null
@@ -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 <boost/foreach.hpp>
+#include <boost/algorithm/string/join.hpp>
+#include <boost/algorithm/string/replace.hpp>
+#include <fstream>
+#include <vector>
+#include <string>
+#include <unistd.h>
+
+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<std::string>& 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 (file)
index 0000000..f400b7e
--- /dev/null
@@ -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<std::string>& ap) const;
+};
+
+}
+
+#endif /* AGENTREMOVECOMMAND_H */
diff --git a/lib/cli/agentsetcommand.cpp b/lib/cli/agentsetcommand.cpp
new file mode 100644 (file)
index 0000000..275287f
--- /dev/null
@@ -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 <boost/foreach.hpp>
+#include <boost/algorithm/string/join.hpp>
+#include <boost/algorithm/string/replace.hpp>
+#include <fstream>
+#include <vector>
+#include <string>
+#include <unistd.h>
+
+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<std::string>& 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 (file)
index 0000000..274ff4e
--- /dev/null
@@ -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<std::string>& ap) const;
+};
+
+}
+
+#endif /* AGENTSETCOMMAND_H */
diff --git a/lib/cli/agentsetupcommand.cpp b/lib/cli/agentsetupcommand.cpp
new file mode 100644 (file)
index 0000000..7da0fc1
--- /dev/null
@@ -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 <boost/foreach.hpp>
+#include <boost/algorithm/string/join.hpp>
+#include <boost/algorithm/string/replace.hpp>
+#include <fstream>
+#include <vector>
+#include <string>
+#include <unistd.h>
+
+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<std::string>(), "The name of the Icinga 2 master")
+               ("master_zone", po::value<std::string>(), "The name of the master zone")
+               ("listen", po::value<std::string>(), "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<std::string>& 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 (file)
index 0000000..2b27e62
--- /dev/null
@@ -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<std::string>& ap) const;
+};
+
+}
+
+#endif /* AGENTSETUPCOMMAND_H */
diff --git a/lib/cli/agentupdateconfigcommand.cpp b/lib/cli/agentupdateconfigcommand.cpp
new file mode 100644 (file)
index 0000000..0e5af15
--- /dev/null
@@ -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 <boost/foreach.hpp>
+#include <boost/algorithm/string/join.hpp>
+#include <boost/algorithm/string/replace.hpp>
+#include <fstream>
+#include <vector>
+#include <string>
+#include <unistd.h>
+
+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<std::string>& 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 (file)
index 0000000..9ca6a93
--- /dev/null
@@ -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<std::string>& ap) const;
+};
+
+}
+
+#endif /* AGENTUPDATECONFIGCOMMAND_H */
diff --git a/lib/cli/agentutility.cpp b/lib/cli/agentutility.cpp
new file mode 100644 (file)
index 0000000..a05e08c
--- /dev/null
@@ -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 (file)
index 0000000..981e302
--- /dev/null
@@ -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 (file)
index 0000000..17db4a2
--- /dev/null
@@ -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 <boost/foreach.hpp>
+#include <boost/algorithm/string/join.hpp>
+#include <boost/algorithm/string/replace.hpp>
+#include <fstream>
+#include <vector>
+#include <string>
+#include <unistd.h>
+
+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<std::string>& 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 (file)
index 0000000..e9be2d0
--- /dev/null
@@ -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<std::string>& ap) const;
+};
+
+}
+
+#endif /* AGENTWIZARDCOMMAND_H */