Class: SNMP4EM::SnmpGetNextRequest

Inherits:
SnmpRequest show all
Defined in:
lib/snmp4em/requests/snmp_getnext_request.rb

Overview

The result of calling SNMP4EM::SNMPCommonRequests#getnext.

Instance Attribute Summary collapse

Attributes inherited from SnmpRequest

#timeout_timer

Instance Method Summary collapse

Methods inherited from SnmpRequest

#format_outgoing_value, #format_value, #init_callbacks, #initialize, #pending_oids

Constructor Details

This class inherits a constructor from SNMP4EM::SnmpRequest

Instance Attribute Details

#snmp_idObject

Returns the value of attribute snmp_id.



6
7
8
# File 'lib/snmp4em/requests/snmp_getnext_request.rb', line 6

def snmp_id
  @snmp_id
end

Instance Method Details

#callback(&block) ⇒ Object

Used to register a callback that is triggered when the query result is ready. The resulting object is passed as a parameter to the block.



9
10
11
# File 'lib/snmp4em/requests/snmp_getnext_request.rb', line 9

def callback &block
  super
end

#errback(&block) ⇒ Object

Used to register a callback that is triggered when query fails to complete successfully.



14
15
16
# File 'lib/snmp4em/requests/snmp_getnext_request.rb', line 14

def errback &block
  super
end

#handle_response(response) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/snmp4em/requests/snmp_getnext_request.rb', line 18

def handle_response(response)  # @private
  super
  
  if response.error_status == :noError
    pending_oids.zip(response.varbind_list).each do |oid, response_vb|
      value = format_value(response_vb)

      if value.is_a? SNMP::ResponseError
        oid[:response] = value
      else
        oid[:response] = [response_vb.name.to_s, format_value(response_vb)]
      end

      oid[:state] = :complete
    end

  else
    error_oid = pending_oids[response.error_index - 1]
    error_oid[:state] = :error
    error_oid[:error] = SNMP::ResponseError.new(response.error_status)
  end

  if pending_oids.empty?
    result = {}

    @oids.each do |oid|
      requested_oid = oid[:requested_string]
      result[requested_oid] = oid[:error] || oid[:response]
    end

    succeed result
    return
  end

  send_msg
end