Class: Rbeapi::Api::Logging
Overview
The Logging class manages logging settings on an EOS node.
Constant Summary collapse
- SEV_NUM =
{ 'emergencies' => 0, 'alerts' => 1, 'critical' => 2, 'errors' => 3, 'warnings' => 4, 'notifications' => 5, 'informational' => 6, 'debugging' => 7 }.freeze
Instance Attribute Summary
Attributes inherited from Entity
Instance Method Summary collapse
-
#add_host(name, opts = {}) ⇒ Boolean
add_host configures a new logging destination host address or hostname to the list of logging destinations.
-
#get ⇒ Hash<Symbol, Object>
get returns the current logging configuration hash extracted from the nodes running configuration.
-
#remove_host(name, opts = {}) ⇒ Boolean
remove_host deletes a logging destination host name or address form the list of logging destinations.
-
#set_console(opts = {}) ⇒ Boolean
set_console configures the global logging level for the console.
-
#set_enable(opts = {}) ⇒ Boolean
set_enable configures the global logging instance on the node as either enabled or disabled.
-
#set_monitor(opts = {}) ⇒ Boolean
set_monitor configures the global logging level for terminals If the default keyword is specified and set to true, then the configuration is defaulted using the default keyword.
-
#set_time_stamp_units(opts = {}) ⇒ Boolean
set_time_stamp_units configures the global logging time_stamp_units If the default keyword is specified and set to true, then the configuration is defaulted using the default keyword.
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, opts = {}) ⇒ 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>
331 332 333 334 335 336 337 |
# File 'lib/rbeapi/api/logging.rb', line 331 def add_host(name, opts = {}) vrf = opts[:vrf] ? "vrf #{opts[:vrf]} " : '' cmd = "logging #{vrf}host #{name}" cmd += " #{opts[:port]}" if opts[:port] cmd += " protocol #{opts[:protocol]}" if opts[:protocol] configure cmd end |
#get ⇒ Hash<Symbol, Object>
get returns the current logging configuration hash extracted from the nodes running configuration.
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/rbeapi/api/logging.rb', line 65 def get response = {} response.merge!(parse_enable) response.merge!(parse_console_level) response.merge!(parse_monitor_level) response.merge!() response.merge!(parse_source) response.merge!(parse_hosts) response end |
#remove_host(name, opts = {}) ⇒ 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>
353 354 355 356 357 358 |
# File 'lib/rbeapi/api/logging.rb', line 353 def remove_host(name, opts = {}) vrf = opts[:vrf] ? "vrf #{opts[:vrf]} " : '' # Hosts are uniquely identified by vrf and address, alone. cmd = "no logging #{vrf}host #{name}" configure cmd end |
#set_console(opts = {}) ⇒ Boolean
set_console configures the global logging level for the console. 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 console <level>
no logging console <level>
default logging console
242 243 244 245 246 247 |
# File 'lib/rbeapi/api/logging.rb', line 242 def set_console(opts = {}) cmd = 'logging console' cmd += " #{opts[:level]}" if opts[:level] cmd = command_builder(cmd, opts) configure cmd 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
214 215 216 217 |
# File 'lib/rbeapi/api/logging.rb', line 214 def set_enable(opts = {}) cmd = command_builder('logging on', opts) configure cmd end |
#set_monitor(opts = {}) ⇒ Boolean
set_monitor configures the global logging level for terminals 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 monitor <level>
no logging monitor <level>
default logging monitor
272 273 274 275 276 277 |
# File 'lib/rbeapi/api/logging.rb', line 272 def set_monitor(opts = {}) cmd = 'logging monitor' cmd += " #{opts[:level]}" if opts[:level] cmd = command_builder(cmd, opts) configure cmd end |
#set_time_stamp_units(opts = {}) ⇒ Boolean
set_time_stamp_units configures the global logging time_stamp_units 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 format timestamp <traditional|high-resolution>
no logging format timestamp <level>
default logging format timestamp
303 304 305 306 307 308 309 310 311 312 313 314 315 |
# File 'lib/rbeapi/api/logging.rb', line 303 def set_time_stamp_units(opts = {}) unit_map = { 'traditional' => ' traditional', 'seconds' => ' traditional', 'high-resolution' => ' high-resolution', 'milliseconds' => ' high-resolution' } units = '' units = unit_map[opts[:units]] if opts[:units] cmd = "logging format timestamp#{units}" cmd = command_builder(cmd, opts) configure cmd end |