From 5d99baa74881271af4e73a2072325b5959ed9371 Mon Sep 17 00:00:00 2001 From: MajesticFalcon Date: Tue, 30 Aug 2016 18:20:31 -0500 Subject: Update tftp.rb --- lib/oxidized/input/tftp.rb | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) (limited to 'lib/oxidized') diff --git a/lib/oxidized/input/tftp.rb b/lib/oxidized/input/tftp.rb index c2f3a16..18028c6 100644 --- a/lib/oxidized/input/tftp.rb +++ b/lib/oxidized/input/tftp.rb @@ -2,27 +2,19 @@ module Oxidized require 'timeout' require 'stringio' require_relative 'cli' - + + begin + require 'net/tftp' + rescue LoadError + raise OxidizedError, 'net/tftp not found: sudo gem install net-tftp' + end + class TFTP < Input - RescueFail = { - :debug => [ - #Net::SSH::Disconnect, - ], - :warn => [ - #RuntimeError, - #Net::SSH::AuthenticationFailed, - ], - } include Input::CLI # TFTP utilizes UDP, there is not a connection. We simply specify an IP and send/receive data. def connect node - begin - require 'net/tftp' - rescue LoadError - raise OxidizedError, 'net/tftp not found: sudo gem install net-tftp' - end @node = node @node.model.cfg['tftp'].each { |cb| instance_exec(&cb) } @@ -38,21 +30,10 @@ module Oxidized config.read end - - # meh not sure if this is the best way, but perhaps better than not implementing send - def send my_proc - my_proc.call - end - - def output - "" - end - private - + def disconnect # TFTP uses UDP, there is no connection to close - #rescue Errno::ECONNRESET, IOError ensure @log.close if Oxidized.config.input.debug? end -- cgit v1.2.1