Class: Cisco::SnmpNotification

Inherits:
NodeUtil
  • Object
show all
Defined in:
lib/cisco_node_utils/snmpnotification.rb

Overview

SnmpNotification - node utility class for SNMP notification management

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(name) ⇒ SnmpNotification

Returns a new instance of SnmpNotification.



22
23
24
25
# File 'lib/cisco_node_utils/snmpnotification.rb', line 22

def initialize(name)
  fail TypeError unless name.is_a?(String)
  @name = name
end

Class Method Details

.notificationsObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/cisco_node_utils/snmpnotification.rb', line 27

def self.notifications
  @notifications = {}
  notifs = config_get('snmpnotification', 'notifications')
  unless notifs.nil?
    notifs.each do |notif|
      @notifications[notif] = SnmpNotification.new(notif)
    end
  end
  @notifications
end

Instance Method Details

#destroyObject



38
39
40
# File 'lib/cisco_node_utils/snmpnotification.rb', line 38

def destroy
  # not needed
end

#enableObject

Get enable



51
52
53
54
55
# File 'lib/cisco_node_utils/snmpnotification.rb', line 51

def enable
  value = config_get('snmpnotification', 'enable', trap_name: @name)
  enabled = value.nil? ? false : true
  enabled
end

#enable=(enable) ⇒ Object

Set enable



43
44
45
46
47
48
# File 'lib/cisco_node_utils/snmpnotification.rb', line 43

def enable=(enable)
  config_set('snmpnotification',
             'enable',
             state:     enable ? '' : 'no',
             trap_name: @name)
end