Class: Puppet::Provider::Banner::CiscoNexus
- Inherits:
-
Object
- Object
- Puppet::Provider::Banner::CiscoNexus
- Defined in:
- lib/puppet/provider/banner/cisco_nexus.rb
Overview
Implementation for the banner type using the Resource API.
Instance Method Summary collapse
- #canonicalize(_context, resources) ⇒ Object
- #get(_context, _names = nil) ⇒ Object
- #set(context, changes) ⇒ Object
- #update(context, name, should) ⇒ Object
- #validate_name(name) ⇒ Object
Instance Method Details
#canonicalize(_context, resources) ⇒ Object
18 19 20 |
# File 'lib/puppet/provider/banner/cisco_nexus.rb', line 18 def canonicalize(_context, resources) resources end |
#get(_context, _names = nil) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/puppet/provider/banner/cisco_nexus.rb', line 33 def get(_context, _names=nil) require 'cisco_node_utils' @banner = Cisco::Banner.new('default') current_state = { name: 'default', motd: "#{@banner.motd}", } [current_state] end |
#set(context, changes) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/puppet/provider/banner/cisco_nexus.rb', line 22 def set(context, changes) changes.each do |name, change| is = change[:is] should = change[:should] if should[:motd] != is[:motd] update(context, name, should) end end end |
#update(context, name, should) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/puppet/provider/banner/cisco_nexus.rb', line 45 def update(context, name, should) validate_name(name) context.notice("Updating '#{name}' with #{should.inspect}") @banner = Cisco::Banner.new('default') @banner.motd = should[:motd] end |
#validate_name(name) ⇒ Object
52 53 54 |
# File 'lib/puppet/provider/banner/cisco_nexus.rb', line 52 def validate_name(name) raise Puppet::ResourceError, '`name` must be `default`' if name != 'default' end |