Class: Oxidized::TFTP

Inherits:
Input
  • Object
show all
Defined in:
lib/oxidized/input/tftp.rb

Constant Summary collapse

RESCUE_FAIL =
{
  Net::TFTPTimeout => :warn
}.freeze

Instance Attribute Summary

Attributes included from Input::CLI

#node

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Input

config_name, #config_name, to_sym, #to_sym

Methods included from Input::CLI

#connect_cli, #disconnect_cli, #get, #initialize, #login, #newline, #password, #post_login, #pre_logout, #username

Methods included from Config::Vars

#vars

Class Method Details

.rescue_failObject



14
15
16
# File 'lib/oxidized/input/tftp.rb', line 14

def self.rescue_fail
  super.merge(RESCUE_FAIL)
end

Instance Method Details

#cmd(file) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/oxidized/input/tftp.rb', line 26

def cmd(file)
  logger.debug "TFTP: #{file} @ #{@node.name}"
  config = StringIO.new
  @tftp.getbinary file, config
  config.rewind
  config.read
end

#connect(node) ⇒ Object

TFTP utilizes UDP, there is not a connection. We simply specify an IP and send/receive data.



19
20
21
22
23
24
# File 'lib/oxidized/input/tftp.rb', line 19

def connect(node)
  @node = node

  @node.model.cfg['tftp'].each { |cb| instance_exec(&cb) }
  @tftp = Net::TFTP.new @node.ip
end