mirror of https://github.com/Icinga/icinga2.git
parent
d16670c4b7
commit
f9209ec5e8
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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 */
|
|
@ -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;
|
||||
}
|
|
@ -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 */
|
|
@ -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;
|
||||
}
|
|
@ -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 */
|
|
@ -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;
|
||||
}
|
|
@ -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 */
|
|
@ -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;
|
||||
}
|
|
@ -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 */
|
|
@ -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;
|
||||
}
|
|
@ -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 */
|
|
@ -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;
|
||||
}
|
|
@ -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 */
|
|
@ -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;
|
||||
}
|
|
@ -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 */
|
|
@ -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;
|
||||
}
|
|
@ -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 */
|
Loading…
Reference in New Issue