Module: ForemanAcd::Concerns::AppInstanceMixins

Extended by:
ActiveSupport::Concern
Included in:
AppInstancesController, UIAcdController
Defined in:
app/controllers/foreman_acd/concerns/app_instance_mixins.rb

Overview

Shared code for AppInstance API and UI controller

Instance Method Summary collapse

Instance Method Details

#collect_host_report_data(app_instance) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/foreman_acd/concerns/app_instance_mixins.rb', line 9

def collect_host_report_data(app_instance)
  report_data = []

  app_instance.foreman_hosts.each do |foreman_host|
    a_host = {
      :id => nil,
      :name => foreman_host.hostname,
      :build => nil,
      :hostUrl => nil,
      :progress_report => foreman_host.last_progress_report.empty? ? [] : JSON.parse(foreman_host.last_progress_report),
    }

    if foreman_host.host.present?
      a_host.update({
        :id => foreman_host.host.id,
        :build => foreman_host.host.build,
        :hostUrl => helpers.current_host_details_path(foreman_host.host),
        :isExistingHost => foreman_host.is_existing_host,
        :powerStatusUrl => power_api_host_path(foreman_host.host),
      })
    end
    report_data << OpenStruct.new(a_host)
  end
  report_data
end