Class: Radfish::VendorDetector

Inherits:
Object
  • Object
show all
Includes:
Debuggable
Defined in:
lib/radfish/vendor_detector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Debuggable

#debug

Constructor Details

#initialize(host:, username:, password:, port: 443, use_ssl: true, verify_ssl: false, host_header: nil) ⇒ VendorDetector

Returns a new instance of VendorDetector.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/radfish/vendor_detector.rb', line 12

def initialize(host:, username:, password:, port: 443, use_ssl: true, verify_ssl: false, host_header: nil)
  @host = host
  @username = username
  @password = password
  @port = port
  @use_ssl = use_ssl
  @verify_ssl = verify_ssl
  @host_header = host_header
  @verbosity = 0
  
  # Use the shared HTTP client
  @http_client = HttpClient.new(
    host: host,
    port: port,
    use_ssl: use_ssl,
    verify_ssl: verify_ssl,
    username: username,
    password: password,
    host_header: host_header,  # Pass host_header to HttpClient
    verbosity: 0,  # Will be updated via verbosity= setter
    retry_count: 2,  # Fewer retries for detection
    retry_delay: 0.5
  )
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



9
10
11
# File 'lib/radfish/vendor_detector.rb', line 9

def host
  @host
end

#passwordObject (readonly)

Returns the value of attribute password.



9
10
11
# File 'lib/radfish/vendor_detector.rb', line 9

def password
  @password
end

#portObject (readonly)

Returns the value of attribute port.



9
10
11
# File 'lib/radfish/vendor_detector.rb', line 9

def port
  @port
end

#use_sslObject (readonly)

Returns the value of attribute use_ssl.



9
10
11
# File 'lib/radfish/vendor_detector.rb', line 9

def use_ssl
  @use_ssl
end

#usernameObject (readonly)

Returns the value of attribute username.



9
10
11
# File 'lib/radfish/vendor_detector.rb', line 9

def username
  @username
end

#verbosityObject

Returns the value of attribute verbosity.



10
11
12
# File 'lib/radfish/vendor_detector.rb', line 10

def verbosity
  @verbosity
end

#verify_sslObject (readonly)

Returns the value of attribute verify_ssl.



9
10
11
# File 'lib/radfish/vendor_detector.rb', line 9

def verify_ssl
  @verify_ssl
end

Instance Method Details

#detectObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/radfish/vendor_detector.rb', line 42

def detect
  debug "Detecting vendor for #{host}:#{port}...", 1, :cyan
  debug "Host header: #{@host_header}" if @host_header
  
  # Try to get the Redfish service root
  debug "Fetching service root...", 2, :yellow
  service_root = fetch_service_root
  
  unless service_root
    debug "Failed to fetch service root from #{host}:#{port}", 1, :red
    return nil
  end
  
  debug "Service root fetched successfully", 2, :green
  vendor = identify_vendor(service_root)
  debug "Detected vendor: #{vendor || 'Unknown'} for #{host}:#{port}", 1, vendor ? :green : :yellow
  
  vendor
end