Class: ForemanRhCloud::CloudPingService

Inherits:
Object
  • Object
show all
Defined in:
app/services/foreman_rh_cloud/cloud_ping_service.rb

Defined Under Namespace

Classes: CertPing

Instance Method Summary collapse

Constructor Details

#initialize(organizations, logger) ⇒ CloudPingService

Returns a new instance of CloudPingService.



37
38
39
40
# File 'app/services/foreman_rh_cloud/cloud_ping_service.rb', line 37

def initialize(organizations, logger)
  @organizations = organizations
  @logger = logger
end

Instance Method Details

#pingObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/services/foreman_rh_cloud/cloud_ping_service.rb', line 42

def ping
  {
    cert_auth: Hash[
      @organizations.map do |org|
        cert_response = CertPing.new(org, @logger).ping
        [
          org,
          {
            success: cert_response.is_a?(RestClient::Response),
            error: (cert_response.is_a?(Exception) ? cert_response&.message || cert_response.inspect : nil),
          },
        ]
      end
    ],
  }
end