Parent

Methods

Class/Module Index [+]

Quicksearch

Facter::EC2::Base

Public Instance Methods

reachable?(retry_limit = 3) click to toggle source
# File lib/facter/ec2/rest.rb, line 17
def reachable?(retry_limit = 3)
  timeout = 0.2
  able_to_connect = false
  attempts = 0

  begin
    Timeout.timeout(timeout) do
      open(@baseurl, :proxy => nil).read
    end
    able_to_connect = true
  rescue OpenURI::HTTPError => e
    if e.message.match /404 Not Found/
      able_to_connect = false
    else
      attempts = attempts + 1
      retry if attempts < retry_limit
    end
  rescue Timeout::Error
    attempts = attempts + 1
    retry if attempts < retry_limit
  rescue *CONNECTION_ERRORS
    attempts = attempts + 1
    retry if attempts < retry_limit
  end

  able_to_connect
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.