mirror of https://github.com/Icinga/icinga2.git
parent
b96e9d26a9
commit
26b9c5a81b
|
@ -24,7 +24,7 @@ endif()
|
|||
add_executable(icinga-app icinga.cpp ${WindowsSources})
|
||||
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
target_link_libraries(icinga-app ${Boost_LIBRARIES} base config)
|
||||
target_link_libraries(icinga-app ${Boost_LIBRARIES} base config cli)
|
||||
|
||||
set_target_properties (
|
||||
icinga-app PROPERTIES
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#include "cli/clicommand.hpp"
|
||||
#include "config/configcompilercontext.hpp"
|
||||
#include "config/configcompiler.hpp"
|
||||
#include "config/configitembuilder.hpp"
|
||||
|
@ -28,7 +29,6 @@
|
|||
#include "base/convert.hpp"
|
||||
#include "base/scriptvariable.hpp"
|
||||
#include "base/context.hpp"
|
||||
#include "base/clicommand.hpp"
|
||||
#include "base/console.hpp"
|
||||
#include "config.h"
|
||||
#include <boost/program_options.hpp>
|
||||
|
|
|
@ -23,7 +23,7 @@ mkclass_target(streamlogger.ti streamlogger.thpp)
|
|||
mkclass_target(sysloglogger.ti sysloglogger.thpp)
|
||||
|
||||
set(base_SOURCES
|
||||
application.cpp application.thpp array.cpp clicommand.cpp configerror.cpp console.cpp context.cpp
|
||||
application.cpp application.thpp array.cpp configerror.cpp console.cpp context.cpp
|
||||
convert.cpp debuginfo.cpp dictionary.cpp dynamicobject.cpp dynamicobject.thpp dynamictype.cpp
|
||||
exception.cpp fifo.cpp filelogger.cpp filelogger.thpp logger.cpp logger.thpp
|
||||
netstring.cpp networkstream.cpp object.cpp objectlock.cpp process.cpp
|
||||
|
|
|
@ -18,11 +18,12 @@
|
|||
set(cli_SOURCES
|
||||
agentaddcommand.cpp agentblackandwhitelistcommand.cpp agentlistcommand.cpp agentremovecommand.cpp
|
||||
agentsetcommand.cpp agentsetupcommand.cpp agentupdateconfigcommand.cpp agentwizardcommand.cpp agentutility.cpp
|
||||
clicommand.cpp
|
||||
daemoncommand.cpp
|
||||
featureenablecommand.cpp featuredisablecommand.cpp featurelistcommand.cpp featureutility.cpp
|
||||
objectlistcommand.cpp
|
||||
pkinewcacommand.cpp pkinewcertcommand.cpp pkisigncsrcommand.cpp pkirequestcommand.cpp pkiticketcommand.cpp
|
||||
repositoryobjectcommand.cpp
|
||||
daemoncommand.cpp
|
||||
)
|
||||
|
||||
if(ICINGA2_UNITY_BUILD)
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "cli/agentaddcommand.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/clicommand.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef AGENTADDCOMMAND_H
|
||||
#define AGENTADDCOMMAND_H
|
||||
|
||||
#include "base/clicommand.hpp"
|
||||
#include "cli/clicommand.hpp"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
|
|
@ -19,9 +19,7 @@
|
|||
|
||||
#include "cli/agentblackandwhitelistcommand.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/clicommand.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include "base/tlsutility.hpp"
|
||||
#include <boost/algorithm/string/case_conv.hpp>
|
||||
#include <fstream>
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef BLACKANDWHITELISTCOMMAND_H
|
||||
#define BLACKANDWHITELISTCOMMAND_H
|
||||
|
||||
#include "base/clicommand.hpp"
|
||||
#include "cli/clicommand.hpp"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "cli/agentlistcommand.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/clicommand.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef AGENTLISTCOMMAND_H
|
||||
#define AGENTLISTCOMMAND_H
|
||||
|
||||
#include "base/clicommand.hpp"
|
||||
#include "cli/clicommand.hpp"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "cli/agentremovecommand.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/clicommand.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef AGENTREMOVECOMMAND_H
|
||||
#define AGENTREMOVECOMMAND_H
|
||||
|
||||
#include "base/clicommand.hpp"
|
||||
#include "cli/clicommand.hpp"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "cli/agentsetcommand.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/clicommand.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef AGENTSETCOMMAND_H
|
||||
#define AGENTSETCOMMAND_H
|
||||
|
||||
#include "base/clicommand.hpp"
|
||||
#include "cli/clicommand.hpp"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "cli/agentsetupcommand.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/clicommand.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef AGENTSETUPCOMMAND_H
|
||||
#define AGENTSETUPCOMMAND_H
|
||||
|
||||
#include "base/clicommand.hpp"
|
||||
#include "cli/clicommand.hpp"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "cli/agentupdateconfigcommand.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/clicommand.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef AGENTUPDATECONFIGCOMMAND_H
|
||||
#define AGENTUPDATECONFIGCOMMAND_H
|
||||
|
||||
#include "base/clicommand.hpp"
|
||||
#include "cli/clicommand.hpp"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "cli/agentwizardcommand.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/clicommand.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef AGENTWIZARDCOMMAND_H
|
||||
#define AGENTWIZARDCOMMAND_H
|
||||
|
||||
#include "base/clicommand.hpp"
|
||||
#include "cli/clicommand.hpp"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
|
||||
******************************************************************************/
|
||||
|
||||
#include "base/clicommand.hpp"
|
||||
#include "cli/clicommand.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/type.hpp"
|
||||
#include "base/serializer.hpp"
|
||||
|
@ -33,9 +33,6 @@
|
|||
using namespace icinga;
|
||||
namespace po = boost::program_options;
|
||||
|
||||
boost::mutex l_RegistryMutex;
|
||||
std::map<std::vector<String>, CLICommand::Ptr> l_Registry;
|
||||
|
||||
std::vector<String> icinga::GetBashCompletionSuggestions(const String& type, const String& word)
|
||||
{
|
||||
std::vector<String> result;
|
||||
|
@ -95,13 +92,25 @@ std::vector<String> icinga::GetFieldCompletionSuggestions(const Type *type, cons
|
|||
return result;
|
||||
}
|
||||
|
||||
boost::mutex& CLICommand::GetRegistryMutex(void)
|
||||
{
|
||||
static boost::mutex mtx;
|
||||
return mtx;
|
||||
}
|
||||
|
||||
std::map<std::vector<String>, CLICommand::Ptr>& CLICommand::GetRegistry(void)
|
||||
{
|
||||
static std::map<std::vector<String>, CLICommand::Ptr> registry;
|
||||
return registry;
|
||||
}
|
||||
|
||||
CLICommand::Ptr CLICommand::GetByName(const std::vector<String>& name)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(l_RegistryMutex);
|
||||
boost::mutex::scoped_lock lock(GetRegistryMutex());
|
||||
|
||||
std::map<std::vector<String>, CLICommand::Ptr>::const_iterator it = l_Registry.find(name);
|
||||
std::map<std::vector<String>, CLICommand::Ptr>::const_iterator it = GetRegistry().find(name);
|
||||
|
||||
if (it == l_Registry.end())
|
||||
if (it == GetRegistry().end())
|
||||
return CLICommand::Ptr();
|
||||
|
||||
return it->second;
|
||||
|
@ -109,14 +118,14 @@ CLICommand::Ptr CLICommand::GetByName(const std::vector<String>& name)
|
|||
|
||||
void CLICommand::Register(const std::vector<String>& name, const CLICommand::Ptr& function)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(l_RegistryMutex);
|
||||
l_Registry[name] = function;
|
||||
boost::mutex::scoped_lock lock(GetRegistryMutex());
|
||||
GetRegistry()[name] = function;
|
||||
}
|
||||
|
||||
void CLICommand::Unregister(const std::vector<String>& name)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(l_RegistryMutex);
|
||||
l_Registry.erase(name);
|
||||
boost::mutex::scoped_lock lock(GetRegistryMutex());
|
||||
GetRegistry().erase(name);
|
||||
}
|
||||
|
||||
RegisterCLICommandHelper::RegisterCLICommandHelper(const String& name, const CLICommand::Ptr& command)
|
||||
|
@ -145,14 +154,14 @@ bool CLICommand::ParseCommand(int argc, char **argv, po::options_description& vi
|
|||
po::positional_options_description& positionalDesc,
|
||||
po::variables_map& vm, String& cmdname, CLICommand::Ptr& command, bool autocomplete)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(l_RegistryMutex);
|
||||
boost::mutex::scoped_lock lock(GetRegistryMutex());
|
||||
|
||||
typedef std::map<std::vector<String>, CLICommand::Ptr>::value_type CLIKeyValue;
|
||||
|
||||
std::vector<String> best_match;
|
||||
int arg_end = 1;
|
||||
|
||||
BOOST_FOREACH(const CLIKeyValue& kv, l_Registry) {
|
||||
BOOST_FOREACH(const CLIKeyValue& kv, GetRegistry()) {
|
||||
const std::vector<String>& vname = kv.first;
|
||||
|
||||
for (int i = 0, k = 1; i < vname.size() && k < argc; i++, k++) {
|
||||
|
@ -204,7 +213,7 @@ void CLICommand::ShowCommands(int argc, char **argv, po::options_description *vi
|
|||
ArgumentCompletionCallback globalArgCompletionCallback,
|
||||
bool autocomplete, int autoindex)
|
||||
{
|
||||
boost::mutex::scoped_lock lock(l_RegistryMutex);
|
||||
boost::mutex::scoped_lock lock(GetRegistryMutex());
|
||||
|
||||
typedef std::map<std::vector<String>, CLICommand::Ptr>::value_type CLIKeyValue;
|
||||
|
||||
|
@ -212,7 +221,7 @@ void CLICommand::ShowCommands(int argc, char **argv, po::options_description *vi
|
|||
int arg_begin = 0;
|
||||
CLICommand::Ptr command;
|
||||
|
||||
BOOST_FOREACH(const CLIKeyValue& kv, l_Registry) {
|
||||
BOOST_FOREACH(const CLIKeyValue& kv, GetRegistry()) {
|
||||
const std::vector<String>& vname = kv.first;
|
||||
|
||||
arg_begin = 0;
|
||||
|
@ -249,7 +258,7 @@ void CLICommand::ShowCommands(int argc, char **argv, po::options_description *vi
|
|||
} else
|
||||
std::cout << "Supported commands: " << std::endl;
|
||||
|
||||
BOOST_FOREACH(const CLIKeyValue& kv, l_Registry) {
|
||||
BOOST_FOREACH(const CLIKeyValue& kv, GetRegistry()) {
|
||||
const std::vector<String>& vname = kv.first;
|
||||
|
||||
if (vname.size() < best_match.size())
|
|
@ -67,6 +67,10 @@ public:
|
|||
boost::program_options::options_description *hiddenDesc = NULL,
|
||||
ArgumentCompletionCallback globalArgCompletionCallback = NULL,
|
||||
bool autocomplete = false, int autoindex = -1);
|
||||
|
||||
private:
|
||||
static boost::mutex& GetRegistryMutex(void);
|
||||
static std::map<std::vector<String>, CLICommand::Ptr>& GetRegistry(void);
|
||||
};
|
||||
|
||||
/**
|
|
@ -22,7 +22,6 @@
|
|||
#include "config/configcompiler.hpp"
|
||||
#include "config/configitembuilder.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/clicommand.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/timer.hpp"
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef DAEMONCOMMAND_H
|
||||
#define DAEMONCOMMAND_H
|
||||
|
||||
#include "base/clicommand.hpp"
|
||||
#include "cli/clicommand.hpp"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "cli/featuredisablecommand.hpp"
|
||||
#include "cli/featureutility.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/clicommand.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include "base/convert.hpp"
|
||||
#include "base/console.hpp"
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef FEATUREDISABLECOMMAND_H
|
||||
#define FEATUREDISABLECOMMAND_H
|
||||
|
||||
#include "base/clicommand.hpp"
|
||||
#include "cli/clicommand.hpp"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "cli/featureenablecommand.hpp"
|
||||
#include "cli/featureutility.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/clicommand.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include "base/convert.hpp"
|
||||
#include "base/console.hpp"
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef FEATUREENABLECOMMAND_H
|
||||
#define FEATUREENABLECOMMAND_H
|
||||
|
||||
#include "base/clicommand.hpp"
|
||||
#include "cli/clicommand.hpp"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "cli/featurelistcommand.hpp"
|
||||
#include "cli/featureutility.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/clicommand.hpp"
|
||||
#include "base/convert.hpp"
|
||||
#include "base/console.hpp"
|
||||
#include <boost/foreach.hpp>
|
||||
|
@ -73,4 +72,4 @@ int FeatureListCommand::Run(const boost::program_options::variables_map& vm, con
|
|||
<< boost::algorithm::join(enabled_features, " ") << "\n";
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef FEATURELISTCOMMAND_H
|
||||
#define FEATURELISTCOMMAND_H
|
||||
|
||||
#include "base/clicommand.hpp"
|
||||
#include "cli/clicommand.hpp"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "cli/featureutility.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/clicommand.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "cli/objectlistcommand.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/clicommand.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include "base/convert.hpp"
|
||||
#include "base/dynamicobject.hpp"
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "base/dictionary.hpp"
|
||||
#include "base/array.hpp"
|
||||
#include "base/clicommand.hpp"
|
||||
#include "cli/clicommand.hpp"
|
||||
#include <ostream>
|
||||
|
||||
namespace icinga
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "cli/pkinewcacommand.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/clicommand.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include "base/tlsutility.hpp"
|
||||
#include <fstream>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef PKINEWCACOMMAND_H
|
||||
#define PKINEWCACOMMAND_H
|
||||
|
||||
#include "base/clicommand.hpp"
|
||||
#include "cli/clicommand.hpp"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "cli/pkinewcertcommand.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/clicommand.hpp"
|
||||
#include "base/tlsutility.hpp"
|
||||
|
||||
using namespace icinga;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef PKINEWCERTCOMMAND_H
|
||||
#define PKINEWCERTCOMMAND_H
|
||||
|
||||
#include "base/clicommand.hpp"
|
||||
#include "cli/clicommand.hpp"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "cli/pkirequestcommand.hpp"
|
||||
#include "remote/jsonrpc.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/clicommand.hpp"
|
||||
#include "base/tlsutility.hpp"
|
||||
#include "base/tlsstream.hpp"
|
||||
#include "base/tcpsocket.hpp"
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef PKIREQUESTCOMMAND_H
|
||||
#define PKIREQUESTCOMMAND_H
|
||||
|
||||
#include "base/clicommand.hpp"
|
||||
#include "cli/clicommand.hpp"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include "cli/pkisigncsrcommand.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/clicommand.hpp"
|
||||
#include "base/tlsutility.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include <fstream>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef PKISIGNCSRCOMMAND_H
|
||||
#define PKISIGNCSRCOMMAND_H
|
||||
|
||||
#include "base/clicommand.hpp"
|
||||
#include "cli/clicommand.hpp"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "cli/pkiticketcommand.hpp"
|
||||
#include "remote/jsonrpc.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/clicommand.hpp"
|
||||
#include "base/tlsutility.hpp"
|
||||
#include "base/tlsstream.hpp"
|
||||
#include "base/tcpsocket.hpp"
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef PKITICKETCOMMAND_H
|
||||
#define PKITICKETCOMMAND_H
|
||||
|
||||
#include "base/clicommand.hpp"
|
||||
#include "cli/clicommand.hpp"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
|
|
@ -19,9 +19,7 @@
|
|||
|
||||
#include "cli/repositoryobjectcommand.hpp"
|
||||
#include "base/logger.hpp"
|
||||
#include "base/clicommand.hpp"
|
||||
#include "base/application.hpp"
|
||||
#include "base/tlsutility.hpp"
|
||||
#include <boost/algorithm/string/case_conv.hpp>
|
||||
#include <fstream>
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef REPOSITORYOBJECTCOMMAND_H
|
||||
#define REPOSITORYOBJECTCOMMAND_H
|
||||
|
||||
#include "base/clicommand.hpp"
|
||||
#include "cli/clicommand.hpp"
|
||||
|
||||
namespace icinga
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue