Class: Puppet::Provider::Tacacs::CiscoNexus

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/provider/tacacs/cisco_nexus.rb

Overview

Implementation for the tacacs type using the Resource API.

Instance Method Summary collapse

Instance Method Details

#canonicalize(_context, resources) ⇒ Object



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

def canonicalize(_context, resources)
  resources
end

#delete(context, name) ⇒ Object



44
45
46
47
48
# File 'lib/puppet/provider/tacacs/cisco_nexus.rb', line 44

def delete(context, name)
  context.notice("Disabling tacacs '#{name}' service")
  @tacacs = Cisco::TacacsServer.new(false)
  @tacacs.destroy
end

#get(_context, _tacacs = nil) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/puppet/provider/tacacs/cisco_nexus.rb', line 34

def get(_context, _tacacs=nil)
  require 'cisco_node_utils'
  current_state = {
    name:   'default',
    enable: Cisco::TacacsServer.enabled,
  }

  [current_state]
end

#set(context, changes) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/puppet/provider/tacacs/cisco_nexus.rb', line 22

def set(context, changes)
  changes.each do |name, change|
    should = change[:should]

    if should[:enable]
      update(context, name, should)
    else
      delete(context, name)
    end
  end
end

#update(context, name, should) ⇒ Object



50
51
52
53
54
# File 'lib/puppet/provider/tacacs/cisco_nexus.rb', line 50

def update(context, name, should)
  context.notice("Enabling tacacs '#{name}' with #{should.inspect}")
  @tacacs = Cisco::TacacsServer.new(false)
  @tacacs.enable
end