27 #ifndef Tools_cluster_SshSocketHandler_h
28 #define Tools_cluster_SshSocketHandler_h
38 #include <libssh/callbacks.h>
39 #include <libssh/libssh.h>
43 #include <condition_variable>
82 virtual bool handle(
int sd,
int events);
101 void log_callback(ssh_session session,
int priority,
const char *message);
112 int echo,
int verify);
322 #endif // Tools_cluster_SshSocketHandler_h
void set_exit_status(int exit_status)
libssh exit status callback This function sets m_command_exit_status to exit_status, sets m_command_exit_status_is_set to true, and then signals m_cond.
void connect_status_callback(float status)
libssh connection status callback.
Collects buffers of output from execution of remote SSH command.
std::shared_ptr< SshSocketHandler > SshSocketHandlerPtr
Smart pointer to SshSocketHandler.
std::condition_variable m_cond
Condition variable signalling connection and command completion.
virtual ~SshSocketHandler()
Destructor.
void write_to_stderr(const char *output, size_t len)
Writes output to stderr Writes output to stderr, prefixing each line with '[' hostname ']'...
SshOutputCollector::Buffer m_stderr_buffer
Current stderr output buffer.
PageArena memory allocator.
std::string m_command
Current command being issued.
SshOutputCollector m_stderr_collector
Output collector for stderr.
Declarations for RawSocketHandler.
bool m_line_prefix_needed_stderr
Line prefix needs to be emitted on next stderr output.
int m_sd
Socket descriptor.
bool issue_command(const std::string &command)
Asynchronously issues a command.
SshOutputCollector m_stdout_collector
Output collector for stdout.
SshOutputCollector m_log_collector
Output collector for logging.
Declarations for CommAddress.
SshOutputCollector::Buffer m_stdout_buffer
Current stdout output buffer.
int auth_callback(const char *prompt, char *buf, size_t len, int echo, int verify)
libssh authorization callback.
std::mutex m_mutex
Mutex for serialzing access to members
int m_state
Current handler state.
SshSocketHandler(const std::string &hostname)
Constructor.
Abstract base class for application raw socket handlers registered with AsyncComm.
std::string m_error
Error message
bool m_line_prefix_needed_stdout
Line prefix needs to be emitted on next stdout output.
bool wait_for_connection(std::chrono::system_clock::time_point deadline)
Waits for connection establishment.
static int ms_libssh_verbosity
Libssh logging verbosity level.
virtual bool handle(int sd, int events)
Socket event handler function.
virtual int poll_interest(int sd)
Returns current polling interest.
bool status(ContextPtr &context, Timer &timer, Status &status)
Runs a status check on the master.
Fixed-size buffer to hold a portion of output.
bool m_channel_is_eof
Flag indicating that current channel is EOF.
const std::string hostname() const
Returns hostname.
Comm * m_comm
Pointer to comm layer.
virtual void deregister(int sd)
Deregisters socket.
bool verify_knownhost()
Verifies host with public key method.
Declarations for SshOutputCollector.
static void set_libssh_verbosity(const std::string &value)
Sets libssh logging verbosity level.
ssh_channel m_channel
libssh channel object
std::string m_hostname
Name of host to connect to.
ssh_callbacks_struct m_callbacks
libssh callbacks
int m_poll_interest
Current polling interest.
bool m_command_exit_status_is_set
Flag indicating that the exit status has been set.
Entry point to AsyncComm service.
void cancel()
Cancels outstanding connection establishment or command execution.
bool m_terminal_output
Redirect output to terminal.
static void enable_debug()
Enables debug logging output.
bool m_cancelled
Flag indicating that outstanding operations should be cancelled.
SshOutputCollector::Buffer m_log_buffer
Current logging output buffer.
Raw socket handler for ssh protocol driver.
void log_callback(ssh_session session, int priority, const char *message)
Writes log messages to logging output collector.
CommAddress m_comm_address
Address of connection.
int m_command_exit_status
Command exit status.
void global_request_callback(ssh_session session, ssh_message message)
libssh global request callback.
void write_to_stdout(const char *output, size_t len)
Writes output to stdout Writes output to stdout, prefixing each line with '[' hostname ']'...
bool wait_for_command_completion()
Waits for command completion.
void dump_log(std::ostream &out)
Writes collected log messages to output stream.
ssh_session m_ssh_session
libssh sesison object
Address abstraction to hold either proxy name or IPv4:port address.
static bool ms_debug_enabled
Flag for enabling debugging output.
bool socket_has_data()
Determines if data available on socket for reading Checks socket descriptor m_sd to see if there is a...
ssh_channel_callbacks_struct m_channel_callbacks
libssh channel callbacks
void set_terminal_output(bool val)
Tells handler to send collected output subsequent output to terminal If val is true, sends any collected stdout or stderr output to terminal and sets m_terminal_output to true which causes any subsequent output collected to be sent to the terminal.