Module: Puppet::Util::NetworkDevice::Cisco_ios::Model::Snmp_host::Base

Defined in:
lib/puppet/util/network_device/cisco_ios/model/snmp_host/base.rb

Class Method Summary collapse

Class Method Details

.register(base) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/puppet/util/network_device/cisco_ios/model/snmp_host/base.rb', line 5

def self.register(base)
  base.base_cmd = "snmp-server host <%= name %>"
  snmp_scope = /^(snmp-server host (\S+)(.*))/
  base.register_scoped :ensure, snmp_scope do
    match do |txt|
      unless txt.nil?
        txt.match(/\S+/) ? :present : :absent
      else
        :absent
      end
    end
    cmd 'sh run'
    default :absent
  end
  base.register_scoped :community, snmp_scope do
    match /^snmp-server host \S+\s+(\S+)/
    cmd 'sh run'
    supported true
    fragment "<%= value %>"
  end
  base.register_scoped :udp_port, snmp_scope do
    match /udp-port (\d+)/
    cmd 'sh run'
    supported true
    fragment "udp-port <%= value %>"
    after :community
  end
end