Skip to content

Commit

Permalink
fixup! Add fake SNMP reset tool
Browse files Browse the repository at this point in the history
  • Loading branch information
kostyanf14 committed Oct 7, 2024
1 parent f316644 commit 96b8b18
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions bin/fake-snmp-reset
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ def send_cmd(qmp_socket, cmd)
end
end

@logger.info 'Initializing UDP socket'
UDPSocket.open do |socket|
socket.bind('0.0.0.0', 'snmp')
@logger.info "Listening on #{socket.local_address.inspect_sockaddr}"
count = 0

count = 0
loop do
@logger.info 'Initializing UDP socket'
UDPSocket.open do |socket|
socket.bind('0.0.0.0', 'snmp')
@logger.info "Listening on #{socket.local_address.inspect_sockaddr}"

loop do
_, addr = socket.recvfrom(512)
@logger.info "Received data from #{addr[3]}:#{addr[1]}"
end

@logger.info "Initializing QMP session for #{qmp_socket_file}"
UNIXSocket.open(qmp_socket_file) do |qmp_socket|
send_cmd(qmp_socket, 'qmp_capabilities')
send_cmd(qmp_socket, 'system_reset')
count += 1
@logger.info "Rebooting... #{count}"
end
@logger.info "Initializing QMP session for #{qmp_socket_file}"
UNIXSocket.open(qmp_socket_file) do |qmp_socket|
send_cmd(qmp_socket, 'qmp_capabilities')
send_cmd(qmp_socket, 'system_reset')
count += 1
@logger.info "Rebooting... #{count}"
end
end

0 comments on commit 96b8b18

Please sign in to comment.