Class: Puppet::Provider::NetworkSnmp::CiscoNexus
- Inherits:
-
Object
- Object
- Puppet::Provider::NetworkSnmp::CiscoNexus
- Defined in:
- lib/puppet/provider/network_snmp/cisco_nexus.rb
Overview
Copyright © 2018 Cisco and/or its affiliates.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Implementation for the network_snmp type using the Resource API.
Instance Method Summary collapse
- #canonicalize(_context, resources) ⇒ Object
- #create(_context, name, should) ⇒ Object
- #delete(_context, name) ⇒ Object
- #get(_context, _names = nil) ⇒ Object
- #set(context, changes) ⇒ Object
- #update(context, name, should) ⇒ Object
Instance Method Details
#canonicalize(_context, resources) ⇒ Object
16 17 18 |
# File 'lib/puppet/provider/network_snmp/cisco_nexus.rb', line 16 def canonicalize(_context, resources) resources end |
#create(_context, name, should) ⇒ Object
44 45 46 |
# File 'lib/puppet/provider/network_snmp/cisco_nexus.rb', line 44 def create(_context, name, should) raise Puppet::ResourceError, "Can't create new SNMP server settings '#{name}' with #{should.inspect}" end |
#delete(_context, name) ⇒ Object
60 61 62 |
# File 'lib/puppet/provider/network_snmp/cisco_nexus.rb', line 60 def delete(_context, name) raise Puppet::ResourceError, "Can't delete SNMP server settings '#{name}'" end |
#get(_context, _names = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/puppet/provider/network_snmp/cisco_nexus.rb', line 20 def get(_context, _names=nil) require 'cisco_node_utils' @network_snmp = Cisco::SnmpServer.new current_state = { name: 'default', enable: @network_snmp.protocol? ? true : false, contact: @network_snmp.contact.empty? ? 'unset' : @network_snmp.contact, location: @network_snmp.location.empty? ? 'unset' : @network_snmp.location, } [current_state] end |
#set(context, changes) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/puppet/provider/network_snmp/cisco_nexus.rb', line 35 def set(context, changes) changes.each do |name, change| should = change[:should] context.updating(name) do update(context, name, should) end end end |
#update(context, name, should) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/puppet/provider/network_snmp/cisco_nexus.rb', line 48 def update(context, name, should) context.notice("Updating '#{name}' with #{should.inspect}") @network_snmp = Cisco::SnmpServer.new if should[:contact] @network_snmp.contact = should[:contact] == 'unset' ? '' : should[:contact] end if should[:location] @network_snmp.location = should[:location] == 'unset' ? '' : should[:location] end @network_snmp.protocol = should[:enable] unless should[:enable].nil? end |