Sha256: 39010e5887978f08d3ea53b732eda58b1a66b32631ee9b0a25ff8b4975a0b310

Contents?: true

Size: 1.24 KB

Versions: 17

Compression:

Stored size: 1.24 KB

Contents

module ForemanInventoryUpload
  class AccountsController < ::ApplicationController
    def index
      organizations = User.current.my_organizations
      labels = organizations.pluck(:id, :name)

      accounts = Hash[
        labels.map do |id, label|
          generate_report_status = status_for(id, ForemanInventoryUpload::Async::GenerateReportJob)
          upload_report_status = status_for(id, ForemanInventoryUpload::Async::UploadReportJob)

          [
            id,
            {
              generate_report_status: generate_report_status,
              upload_report_status: upload_report_status,
              label: label,
            },
          ]
        end
      ]

      render json: {
        autoUploadEnabled: Setting[:allow_auto_inventory_upload],
        hostObfuscationEnabled: Setting[:obfuscate_inventory_hostnames],
        ipsObfuscationEnabled: Setting[:obfuscate_inventory_ips],
        cloudToken: Setting[:rh_cloud_token],
        excludePackages: Setting[:exclude_installed_packages],
        accounts: accounts,
      }, status: :ok
    end

    private

    def status_for(label, job_class)
      label = job_class.output_label(label)
      ForemanInventoryUpload::Async::ProgressOutput.get(label)&.status
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
foreman_rh_cloud-1.0.17 app/controllers/foreman_inventory_upload/accounts_controller.rb
foreman_rh_cloud-2.0.17 app/controllers/foreman_inventory_upload/accounts_controller.rb
foreman_rh_cloud-2.0.16 app/controllers/foreman_inventory_upload/accounts_controller.rb
foreman_rh_cloud-1.0.16 app/controllers/foreman_inventory_upload/accounts_controller.rb
foreman_rh_cloud-1.0.15 app/controllers/foreman_inventory_upload/accounts_controller.rb
foreman_rh_cloud-2.0.15 app/controllers/foreman_inventory_upload/accounts_controller.rb
foreman_rh_cloud-3.0.15 app/controllers/foreman_inventory_upload/accounts_controller.rb
foreman_rh_cloud-3.0.14 app/controllers/foreman_inventory_upload/accounts_controller.rb
foreman_rh_cloud-2.0.14 app/controllers/foreman_inventory_upload/accounts_controller.rb
foreman_rh_cloud-1.0.14 app/controllers/foreman_inventory_upload/accounts_controller.rb
foreman_rh_cloud-0.9.14 app/controllers/foreman_inventory_upload/accounts_controller.rb
foreman_rh_cloud-0.9.13.1 app/controllers/foreman_inventory_upload/accounts_controller.rb
foreman_rh_cloud-1.0.13.1 app/controllers/foreman_inventory_upload/accounts_controller.rb
foreman_rh_cloud-2.0.13.1 app/controllers/foreman_inventory_upload/accounts_controller.rb
foreman_rh_cloud-0.9.13 app/controllers/foreman_inventory_upload/accounts_controller.rb
foreman_rh_cloud-1.0.13 app/controllers/foreman_inventory_upload/accounts_controller.rb
foreman_rh_cloud-2.0.13 app/controllers/foreman_inventory_upload/accounts_controller.rb