Class: XClarityClient::Discover

Inherits:
Object
  • Object
show all
Defined in:
lib/xclarity_client/discover.rb

Constant Summary collapse

RESOURCE =
'/aicc'.freeze

Class Method Summary collapse

Class Method Details

.responds?(ipAddress, port) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/xclarity_client/discover.rb', line 6

def self.responds?(ipAddress, port)
  conf = Faraday.new(url: build_uri(ipAddress, port).to_s) do |faraday|
    faraday.request  :url_encoded             # form-encode POST params
    faraday.response :logger, $lxca_log.log   # log requests to STDOUT -- This line, should be uncommented if you wanna inspect the URL Request
    faraday.adapter  Faraday.default_adapter  # make requests with Net::HTTP
    faraday.ssl[:verify] = false
  end

  begin
    response = conf.get do |req|
      req.url RESOURCE
      req.options.timeout = 5           # open/read timeout in seconds
      req.options.open_timeout = 6      # connection open timeout in seconds
    end
  rescue Exception
    return false
  end

  return true if %w(200 302).include? response.status.to_s
  false
end