Class: Cisco::SyslogFacility

Inherits:
NodeUtil show all
Defined in:
lib/cisco_node_utils/syslog_facility.rb

Overview

SyslogFacility - node utility class for Syslog facility severity management

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from NodeUtil

#client, client, #config_get, config_get, #config_get_default, config_get_default, config_set, #config_set, #get, #ios_xr?, #nexus?, node, #node, platform, #platform, supports?, #supports?

Constructor Details

#initialize(opts, instantiate = true) ⇒ SyslogFacility

Returns a new instance of SyslogFacility


26
27
28
29
30
31
# File 'lib/cisco_node_utils/syslog_facility.rb', line 26

def initialize(opts, instantiate=true)
  @facility = opts['facility']
  @level = opts['level']

  create if instantiate
end

Instance Attribute Details

#facilityObject (readonly)

Returns the value of attribute facility


24
25
26
# File 'lib/cisco_node_utils/syslog_facility.rb', line 24

def facility
  @facility
end

#levelObject (readonly)

Returns the value of attribute level


24
25
26
# File 'lib/cisco_node_utils/syslog_facility.rb', line 24

def level
  @level
end

Class Method Details

.facilitiesObject


33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/cisco_node_utils/syslog_facility.rb', line 33

def self.facilities
  keys = %w(facility level)
  hash = {}
  facility_key_list = config_get('syslog_facility', 'facility')
  return hash if facility_key_list.nil?

  facility_key_list.each do |id|
    hash[id[0]] = SyslogFacility.new(Hash[keys.zip(id)], false)
  end

  hash
end

Instance Method Details

#==(other) ⇒ Object


46
47
48
# File 'lib/cisco_node_utils/syslog_facility.rb', line 46

def ==(other)
  facility == other.facility && level == other.level
end

#createObject


50
51
52
53
# File 'lib/cisco_node_utils/syslog_facility.rb', line 50

def create
  config_set('syslog_facility', 'facility', state: '', facility: @facility,
              level: @level)
end

#destroyObject


55
56
57
58
# File 'lib/cisco_node_utils/syslog_facility.rb', line 55

def destroy
  config_set('syslog_facility', 'facility', state: 'no',
              facility: @facility, level: @level)
end