Method: Cisco::Client#get

Defined in:
lib/cisco_node_utils/client/client.rb

#get(data_format: :cli, command: nil, context: nil, value: nil, **_kwargs) ⇒ String, ...

Get the given state from the device.

Unlike set() this will not clear the CLI cache; multiple calls with the same parameters may return cached data rather than querying the device repeatedly.

Parameters:

  • data_format (defaults to: :cli)

    one of Cisco::DATA_FORMATS. Default is :cli

  • command (String) (defaults to: nil)

    the get command to execute

  • context (String, Array<String>) (defaults to: nil)

    Context to refine/filter the results

  • value (String, Regexp) (defaults to: nil)

    Specific key or regexp to look up

  • kwargs

    data-format-specific args

Returns:

  • (String, Hash, nil)

    The state found, or nil if not found.

Raises:



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/cisco_node_utils/client/client.rb', line 202

def get(data_format: :cli,
        command:     nil,
        context:     nil,
        value:       nil,
        **_kwargs)
  # subclasses will generally want to call Client.munge_to_array()
  # on context and/or value before calling super()
  fail Cisco::RequestNotSupported unless self.supports?(data_format)
  Cisco::Logger.debug("Get state using data format '#{data_format}'")
  Cisco::Logger.debug("  executing command:\n    #{command}") \
    unless command.nil? || command.empty?
  Cisco::Logger.debug("  with context:\n    #{context.join("\n    ")}") \
    unless context.nil? || context.empty?
  Cisco::Logger.debug("  to get value:     #{value}") \
    unless value.nil?
  # to be implemented by subclasses
end