Class: Puppet::Provider::SyslogFacility::CiscoNexus

Inherits:
ResourceApi::SimpleProvider
  • Object
show all
Defined in:
lib/puppet/provider/syslog_facility/cisco_nexus.rb

Overview

Implementation for the syslog_facility type using the Resource API.

Instance Method Summary collapse

Instance Method Details

#canonicalize(_context, resources) ⇒ Object



18
19
20
# File 'lib/puppet/provider/syslog_facility/cisco_nexus.rb', line 18

def canonicalize(_context, resources)
  resources
end

#delete(context, name) ⇒ Object



56
57
58
59
60
# File 'lib/puppet/provider/syslog_facility/cisco_nexus.rb', line 56

def delete(context, name)
  context.notice("Destroying '#{name}'")
  @syslog_facilities = Cisco::SyslogFacility.facilities
  @syslog_facilities[name].destroy if @syslog_facilities[name]
end

#get(_context, facilities = nil) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/puppet/provider/syslog_facility/cisco_nexus.rb', line 22

def get(_context, facilities=nil)
  require 'cisco_node_utils'
  current_states = []
  @syslog_facilities = Cisco::SyslogFacility.facilities
  if facilities.nil? || facilities.empty?
    @syslog_facilities.each do |facility, instance|
      current_states << get_current_state(facility, instance)
    end
  else
    facilities.each do |facility|
      individual_facility = @syslog_facilities[facility]
      next if individual_facility.nil?
      current_states << get_current_state(facility, individual_facility)
    end
  end
  current_states
end

#get_current_state(facility, instance) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/puppet/provider/syslog_facility/cisco_nexus.rb', line 40

def get_current_state(facility, instance)
  {
    name:   facility,
    ensure: 'present',
    level:  instance.level,
  }
end

#update(context, name, should) ⇒ Object Also known as: create



48
49
50
51
52
# File 'lib/puppet/provider/syslog_facility/cisco_nexus.rb', line 48

def update(context, name, should)
  context.notice("Setting '#{name}' with #{should.inspect}")
  Cisco::SyslogFacility.new('facility' => name,
                            'level'    => should[:level].to_s)
end