Method: Rbeapi::Client::Node#run_commands

Defined in:
lib/rbeapi/client.rb

#run_commands(commands, opts = {}) ⇒ Object

This method will send the ordered list of commands to the destination node using the transport. It is also response for inserting enable onto the command stack and popping the enable result on the response.

Parameters:

  • commands (Array)

    The ordered list of commands to send to the destination node.

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

    a customizable set of options

Options Hash (opts):

  • encoding (String)

    The encoding scheme to use for sending and receive eAPI requests. This argument is optional. Valid values include json or text. The default is json.

  • 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).



466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
# File 'lib/rbeapi/client.rb', line 466

def run_commands(commands, opts = {})
  encoding = opts.fetch(:encoding, 'json')
  commands = [*commands] unless commands.respond_to?('each')
  commands = commands.dup

  if @enablepwd
    commands.insert(0, 'cmd' => 'enable', 'input' => @enablepwd)
  else
    commands.insert(0, 'enable')
  end

  opts[:format] = encoding
  response = @connection.execute(commands, opts)
  response.shift
  response
end