Class: Rbeapi::Api::Logging

Inherits:
Entity
  • Object
show all
Defined in:
lib/rbeapi/api/logging.rb

Overview

The Logging class manages logging settings on an EOS node.

Instance Attribute Summary

Attributes inherited from Entity

#config, #error, #node

Instance Method Summary collapse

Methods inherited from Entity

#command_builder, #configure, #configure_interface, #get_block, #initialize, instance

Constructor Details

This class inherits a constructor from Rbeapi::Api::Entity

Instance Method Details

#add_host(name) ⇒ Boolean

add_host configures a new logging destination host address or hostname to the list of logging destinations. If the host is already configured in the list of destinations, this method will return successfully.

Commands

logging host <name>

Parameters:

  • name (String)

    The host name or ip address of the destination node to send logging information to.

Returns:

  • (Boolean)

    Returns true if the command completed successfully.

Since:

  • eos_version 4.13.7M



136
137
138
# File 'lib/rbeapi/api/logging.rb', line 136

def add_host(name)
  configure "logging host #{name}"
end

#getHash<Symbol, Object>

get returns the current logging configuration hash extracted from the nodes running configuration.

Examples:

{
  enable: [true, false],
  hosts: array<strings>
}

Returns:

  • (Hash<Symbol, Object>)

    Returns the logging resource as a hash object from the nodes current configuration.



55
56
57
58
59
60
# File 'lib/rbeapi/api/logging.rb', line 55

def get
  response = {}
  response.merge!(parse_enable)
  response.merge!(parse_hosts)
  response
end

#parse_enableHash<Symbol, Object>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

parse_enable scans the nodes current running configuration and extracts the current enabled state of the logging facility. The logging enable command is expected to always be in the node’s configuration. This methods return value is intended to be merged into the logging resource hash.

Returns:

  • (Hash<Symbol, Object>)

    Returns the resource hash attribute.



72
73
74
75
# File 'lib/rbeapi/api/logging.rb', line 72

def parse_enable
  value = /no logging on/ !~ config
  { enable: value }
end

#remove_host(name) ⇒ Boolean

remove_host deletes a logging destination host name or address form the list of logging destinations. If the host is not in the list of configured hosts, this method will still return successfully.

Commands

no logging host <name>

Parameters:

  • name (String)

    The host name or ip address of the destination host to remove from the nodes current configuration.

Returns:

  • (Boolean)

    Returns true if the commands completed successfully.

Since:

  • eos_version 4.13.7M



154
155
156
# File 'lib/rbeapi/api/logging.rb', line 154

def remove_host(name)
  configure "no logging host #{name}"
end

#set_enable(opts = {}) ⇒ Boolean

set_enable configures the global logging instance on the node as either enabled or disabled. If the enable keyword is set to true then logging is globally enabled and if set to false, it is globally disabled. If the default keyword is specified and set to true, then the configuration is defaulted using the default keyword. The default keyword option takes precedence over the enable keyword if both options are specified.

Commands

logging on
no logging on
default logging on

Parameters:

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

    Optional keyword arguments

Options Hash (opts):

  • enable (Boolean)

    Enables logging globally if value is true or disabled logging globally if value is false.

  • default (Boolean)

    Configure the ip address value using the default keyword.

Returns:

  • (Boolean)

    Returns true if the command completed successfully.

Since:

  • eos_version 4.13.7M



117
118
119
120
# File 'lib/rbeapi/api/logging.rb', line 117

def set_enable(opts = {})
  cmd = command_builder('logging on', opts)
  configure cmd
end