Class: Cisco::SnmpGroup

Inherits:
NodeUtil show all
Defined in:
lib/cisco_node_utils/snmpgroup.rb

Overview

SnmpGroup - node utility class for SNMP group configuration management

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from NodeUtil

#client, client, #config_get, config_get, #config_get_default, config_get_default, config_set, #config_set, #get, #ios_xr?, #nexus?, node, #node, platform, #platform, supports?, #supports?

Constructor Details

#initialize(name) ⇒ SnmpGroup


31
32
33
34
# File 'lib/cisco_node_utils/snmpgroup.rb', line 31

def initialize(name)
  fail TypeError unless name.is_a?(String)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name


29
30
31
# File 'lib/cisco_node_utils/snmpgroup.rb', line 29

def name
  @name
end

Class Method Details

.exists?(group) ⇒ Boolean


47
48
49
50
51
52
# File 'lib/cisco_node_utils/snmpgroup.rb', line 47

def self.exists?(group)
  fail ArgumentError if group.empty?
  fail TypeError unless group.is_a? String
  groups = config_get('snmp_group', 'group')
  (!groups.nil? && groups.include?(group))
end

.groupsObject


36
37
38
39
40
41
42
43
44
45
# File 'lib/cisco_node_utils/snmpgroup.rb', line 36

def self.groups
  group_ids = config_get('snmp_group', 'group')
  return {} if group_ids.nil?

  hash = {}
  group_ids.each do |name|
    hash[name] = SnmpGroup.new(name)
  end
  hash
end