Behaviours: gen_server.
config() = #{action => parameter | request | revoke, service_id => binary(), queue => atom(), user_info => watts_userinfo:userinfo() | undefined, cred_state => binary() | undefined, params => map()}
output() = #{channel_id => any(), process_id => any(), cmd => string() | undefined, std_out => [binary()], std_err => [binary()], exit_status => any()}
result() = {ok, Result::map(), Output::output()} | {error, Reason::atom() | tuple(), Output::output()} | {error, Reason::atom() | tuple()}
state() = #state{action = any(), client = any(), service_info = undefined | watts_service:info(), user_info = any(), params = any(), queue = any(), job_id = any(), cred_state = any(), connection = any(), con_type = any(), cmd_line = any(), cmd_stdin = undefined | binary(), cmd_output = undefined | output(), error = any()}
add_user_info_if_present/4* | add the information about the user to the parameter. |
close_connection/2* | close the connection. |
code_change/3 | only returns the current state. |
connect_to_service/1* | connect to the plugin, either locally or via ssh. |
create_cmd_and_stdin/3* | create the command to execute and the stdin input. |
create_command_and_update_state/5* | create the command line command and update the state with it. |
create_result/1* | create the result from the command output. |
get_connection_info/1* | return the connection info from the service info. |
get_plugin/1* | get the plugin. |
handle_call/3 | hande the only call, the action request. |
handle_cast/2 | each step in the process of executing the plugin is done here. |
handle_exec_message/3* | handle the messages from the exec module, when done send the result. |
handle_info/2 | handle the responses from either ssh or the executed plugin. |
handle_ssh_message/3* | handle the incomming ssh messages and when done trigger sending result. |
init/1 | init the gen_server process, this just returns an empty state. |
kill/1* | kill this process and the execution. |
maybe_local_stdin_send/2* | |
maybe_ssh_stdin_send/3* | |
output/1* | create a valid basic output. |
parameter_update/3* | return the config and request parameter, if not performing parameter. |
prepare_action/1* | prepare the execution by creating the command line and connecting. |
request_action/2 | Request the action configured in the config passed. |
run_plugin/1* | prepare and run a plugin. |
run_plugin/5* | run the plugin with its parameter. |
send_reply/2* | send the reply if not yet done. |
send_result/1* | send the result to the requesting process and stop this one. |
start/0 | start the gen_server process (not linked). |
start_link/0 | start the gen_server process in a linked manner. |
stop/1 | stop the gen_server. |
terminate/2 | check if crashed and send a reply then, if not do nothing. |
timeout_result/0* | generate a timout result. |
trigger_sending/0* | trigger sending the result. |
update_exit_and_send/2* | update the exit status of the command and trigger sending the result. |
update_exit_status/2* | update the exit status in the cmd output. |
update_std_out_err/3* | update the std out or error list of inputs. |
add_user_info_if_present(ScriptParam::map(), UserInfo::watts_userinfo:info() | undefined, ServiceId::binary(), AddAccessToken::boolean()) -> map()
add the information about the user to the parameter
close_connection(Connection::any(), X2::ssh | local) -> ok
close the connection
only returns the current state.
connect_to_service(Info::watts_service:connection()) -> {ok, any()}
connect to the plugin, either locally or via ssh.
create_cmd_and_stdin(Cmd::binary(), EncJson::binary(), X3::boolean()) -> {string(), undefined | binary()}
create the command to execute and the stdin input
create_command_and_update_state(Cmd::binary(), UserInfo::watts_userinfo:info(), ServiceInfo::watts_service:info(), X4::{ok, any()}, State::state()) -> {ok, state()}
create the command line command and update the state with it.
create the result from the command output.
get_connection_info(X1::watts_service:info()) -> {ok, watts_service:connection()}
return the connection info from the service info
get_plugin(X1::watts_service:info()) -> {ok, binary()}
get the plugin
handle_call(Request::{request_action, config()} | any(), From::any(), State::state()) -> {noreply, state(), pos_integer()} | {reply, ignored, state()}
hande the only call, the action request. This will start the process to iterate throught all the needed steps.
each step in the process of executing the plugin is done here. The actions performed are:
handle the messages from the exec module, when done send the result.
handle the responses from either ssh or the executed plugin.
See also: handle_exec_message/3, handle_ssh_message/3.
handle the incomming ssh messages and when done trigger sending result.
init(X1::noparams) -> {ok, state()}
init the gen_server process, this just returns an empty state.
kill(State) -> any()
kill this process and the execution. this is called after a timeout.
maybe_local_stdin_send(Id::any(), Stdin::undefined | binary()) -> ok
maybe_ssh_stdin_send(Connection::any(), ChannelId::any(), Stdin::undefined | binary()) -> ok
output(Output::map()) -> output()
create a valid basic output
parameter_update(X1::atom(), ServiceInfo::watts_service:info(), State::state()) -> map()
return the config and request parameter, if not performing parameter.
prepare the execution by creating the command line and connecting.
Request the action configured in the config passed. The action can be one of the suppoerted actions:
prepare and run a plugin
run_plugin(Cmd::string(), Stdin::binary() | undefined, X3::ssh | local, Connection::any(), State::state()) -> {ok, state()}
run the plugin with its parameter.
The results will be sent async to this process and are handled by the
handle_info/2
function.
send the reply if not yet done.
send the result to the requesting process and stop this one.
start() -> {ok, pid()}
start the gen_server process (not linked).
start_link() -> {ok, pid()}
start the gen_server process in a linked manner.
stop(Pid::pid()) -> ok
stop the gen_server.
terminate(Reason::any(), State::state()) -> ok
check if crashed and send a reply then, if not do nothing.
timeout_result() -> result()
generate a timout result
trigger_sending() -> ok
trigger sending the result.
update the exit status of the command and trigger sending the result
update the exit status in the cmd output
update the std out or error list of inputs.
Generated by EDoc