Sha256: 1ce4a383f4c179fd0253fb6580c5eb9101b2c2e4ebbbfeb4d7bb1b51dd4f77d0

Contents?: true

Size: 1.35 KB

Versions: 3

Compression:

Stored size: 1.35 KB

Contents

module ForemanRhCloud
  # Macro to fetch remediation playbook from cloud.redhat.com
  module TemplateRendererHelper
    extend ActiveSupport::Concern
    extend ApipieDSL::Module

    apipie :class, 'Macros related to Red Hat cloud interface' do
      name 'RHCloud'
      sections only: %w[all jobs]
    end

    apipie :method, 'Returns a playbook generated from Red Hat cloud recommendations' do
      required :hit_remediation_pairs, String, desc: 'JSON-encoded array of hashes in the form of [{hit_id: 1, remediation_id: 2}, ...]'
      returns String, desc: 'Playbook generated for the specific recommendations and hosts'
    end
    def remediations_playbook(hit_remediation_pairs)
      hit_remediation_pairs = JSON.parse(hit_remediation_pairs)
      retriever = ForemanRhCloud::HitRemediationsRetriever.new(hit_remediation_pairs, logger: template_logger)
      retriever.create_playbook
    end

    apipie :method, 'Returns a Red Hat remediation playbook compiled on console.redhat.com' do
      required :remediation_path, String, desc: ''
      returns String, desc: 'Playbook downloaded from the cloud'
    end
    def download_rh_playbook(playbook_url)
      retriever = ForemanRhCloud::UrlRemediationsRetriever.new(url: playbook_url, logger: template_logger)

      cached("rh_playbook_#{playbook_url}") do
        retriever.create_playbook
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman_rh_cloud-5.0.35 app/services/foreman_rh_cloud/template_renderer_helper.rb
foreman_rh_cloud-5.0.34 app/services/foreman_rh_cloud/template_renderer_helper.rb
foreman_rh_cloud-5.0.33 app/services/foreman_rh_cloud/template_renderer_helper.rb