Class: Puppet::Provider::SnmpNotification::CiscoNexus
- Inherits:
-
Object
- Object
- Puppet::Provider::SnmpNotification::CiscoNexus
- Defined in:
- lib/puppet/provider/snmp_notification/cisco_nexus.rb
Overview
Implementation for the snmp_notification type using the Resource API.
Instance Method Summary collapse
- #canonicalize(_context, resources) ⇒ Object
- #get(_context, notifications = nil) ⇒ Object
- #get_current_state(name, instance) ⇒ Object
- #set(context, changes) ⇒ Object
- #update(context, name, should) ⇒ Object
Instance Method Details
#canonicalize(_context, resources) ⇒ Object
18 19 20 |
# File 'lib/puppet/provider/snmp_notification/cisco_nexus.rb', line 18 def canonicalize(_context, resources) resources end |
#get(_context, notifications = nil) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/puppet/provider/snmp_notification/cisco_nexus.rb', line 39 def get(_context, notifications=nil) require 'cisco_node_utils' current_states = [] if notifications.nil? || notifications.empty? @snmp_notifications = Cisco::SnmpNotification.notifications @snmp_notifications.each do |name, instance| current_states << get_current_state(name, instance) end else notifications.each do |notification| @snmp_notifications = Cisco::SnmpNotification.notifications individual_notification = @snmp_notifications[notification] next if individual_notification.nil? current_states << get_current_state(notification, individual_notification) end end current_states end |
#get_current_state(name, instance) ⇒ Object
58 59 60 61 62 63 |
# File 'lib/puppet/provider/snmp_notification/cisco_nexus.rb', line 58 def get_current_state(name, instance) { name: name, enable: instance.enable, } end |
#set(context, changes) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/puppet/provider/snmp_notification/cisco_nexus.rb', line 22 def set(context, changes) changes.each do |name, change| is = if context.type.feature?('simple_get_filter') change.key?(:is) ? change[:is] : (get(context, [name]) || []).find { |r| r[:name] == name } else change.key?(:is) ? change[:is] : (get(context) || []).find { |r| r[:name] == name } end context.type.check_schema(is) unless change.key?(:is) should = change[:should] if should != is update(context, name, should) end end end |
#update(context, name, should) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/puppet/provider/snmp_notification/cisco_nexus.rb', line 65 def update(context, name, should) context.notice("Updating '#{name}' with #{should.inspect}") @snmp_notifications = Cisco::SnmpNotification.notifications snmp_notification = @snmp_notifications[name] snmp_notification = Cisco::SnmpNotification.new(name) if snmp_notification.nil? snmp_notification.enable = should[:enable] unless should[:enable].nil? end |