Method: Rbeapi::Eapilib::EapiConnection#execute

Defined in:
lib/rbeapi/eapilib.rb

#execute(commands, opts = {}) ⇒ Array<Hash>

Executes the commands on the destination node and returns the response from the node.

Parameters:

  • commands (Array)

    The ordered list of commands to execute on the destination node.

  • opts (Hash) (defaults to: {})

    Optional keyword arguments.

Options Hash (opts):

  • encoding (String)

    Used to specify the encoding to be used for the response. Valid encoding values are json or text.

  • open_timeout (Float)

    Number of seconds to wait for the eAPI connection to open.

  • read_timeout (Float)

    Number of seconds to wait for one block of eAPI results to be read (via one read(2) call).

Returns:

  • (Array<Hash>)

    This method will return the array of responses for each command executed on the node.

Raises:

  • (CommandError)

    Raises a CommandError if rescued from the send method and adds the list of commands to the exception message.

  • (ConnectionError)

    Raises a ConnectionError if rescued and adds the list of commands to the exception message.



321
322
323
324
325
326
327
328
329
330
# File 'lib/rbeapi/eapilib.rb', line 321

def execute(commands, opts = {})
  @error = nil
  request = request(commands, opts)
  response = send(request, opts)
  return response['result']
rescue ConnectionError, CommandError => exc
  exc.commands = commands
  @error = exc
  raise
end