2019-02-25 14:48:22 +01:00
|
|
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
2014-11-23 12:35:13 +01:00
|
|
|
|
2015-01-12 14:29:08 +01:00
|
|
|
#ifndef CONSOLECOMMAND_H
|
|
|
|
#define CONSOLECOMMAND_H
|
2014-11-23 12:35:13 +01:00
|
|
|
|
|
|
|
#include "cli/clicommand.hpp"
|
2015-11-02 16:35:21 +01:00
|
|
|
#include "base/exception.hpp"
|
2015-11-05 14:29:45 +01:00
|
|
|
#include "base/scriptframe.hpp"
|
2019-04-05 09:30:26 +02:00
|
|
|
#include "base/tlsstream.hpp"
|
|
|
|
#include "remote/url.hpp"
|
|
|
|
|
2014-11-23 12:35:13 +01:00
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
2015-01-12 14:29:08 +01:00
|
|
|
* The "console" CLI command.
|
2014-11-23 12:35:13 +01:00
|
|
|
*
|
|
|
|
* @ingroup cli
|
|
|
|
*/
|
2018-01-04 06:11:04 +01:00
|
|
|
class ConsoleCommand final : public CLICommand
|
2014-11-23 12:35:13 +01:00
|
|
|
{
|
|
|
|
public:
|
2015-01-12 14:29:08 +01:00
|
|
|
DECLARE_PTR_TYPEDEFS(ConsoleCommand);
|
2014-11-23 12:35:13 +01:00
|
|
|
|
2018-01-04 04:25:35 +01:00
|
|
|
static void StaticInitialize();
|
2015-11-05 14:29:45 +01:00
|
|
|
|
2018-01-04 05:12:56 +01:00
|
|
|
String GetDescription() const override;
|
|
|
|
String GetShortDescription() const override;
|
|
|
|
ImpersonationLevel GetImpersonationLevel() const override;
|
|
|
|
void InitParameters(boost::program_options::options_description& visibleDesc,
|
2017-12-19 15:50:05 +01:00
|
|
|
boost::program_options::options_description& hiddenDesc) const override;
|
2018-01-04 05:12:56 +01:00
|
|
|
int Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const override;
|
2015-11-02 16:35:21 +01:00
|
|
|
|
2019-04-05 09:30:26 +02:00
|
|
|
static int RunScriptConsole(ScriptFrame& scriptFrame, const String& connectAddr = String(),
|
2017-12-19 15:50:05 +01:00
|
|
|
const String& session = String(), const String& commandOnce = String(), const String& commandOnceFileName = String(),
|
|
|
|
bool syntaxOnly = false);
|
2015-11-05 14:29:45 +01:00
|
|
|
|
2015-11-02 16:35:21 +01:00
|
|
|
private:
|
|
|
|
mutable boost::mutex m_Mutex;
|
|
|
|
mutable boost::condition_variable m_CV;
|
|
|
|
|
2019-07-25 14:34:29 +02:00
|
|
|
static Shared<AsioTlsStream>::Ptr Connect();
|
2019-04-05 09:30:26 +02:00
|
|
|
|
|
|
|
static Value ExecuteScript(const String& session, const String& command, bool sandboxed);
|
|
|
|
static Array::Ptr AutoCompleteScript(const String& session, const String& command, bool sandboxed);
|
|
|
|
|
|
|
|
static Dictionary::Ptr SendRequest();
|
2015-11-02 16:35:21 +01:00
|
|
|
|
|
|
|
#ifdef HAVE_EDITLINE
|
|
|
|
static char *ConsoleCompleteHelper(const char *word, int state);
|
|
|
|
#endif /* HAVE_EDITLINE */
|
|
|
|
|
2015-11-05 14:29:45 +01:00
|
|
|
static void BreakpointHandler(ScriptFrame& frame, ScriptError *ex, const DebugInfo& di);
|
|
|
|
|
2014-11-23 12:35:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-01-12 14:29:08 +01:00
|
|
|
#endif /* CONSOLECOMMAND_H */
|