Sha256: 28a37b97526117a639b807e7cd997b4afff924c8e274d3a7ccb1278673bc04a4

Contents?: true

Size: 1.8 KB

Versions: 66

Compression:

Stored size: 1.8 KB

Contents

require 'host_info'

module Katello
  module Host
    class InfoProvider < ::HostInfo::Provider
      def host_info
        info = {}
        info['parameters'] = {
          'kt_env' => host.lifecycle_environment.try(:label), #deprecated
          'kt_cv' => host.content_view.try(:label), #deprecated
          'foreman_host_collections' => host.host_collections.map(&:name),
          'lifecycle_environment' => host.lifecycle_environment.try(:label),

          'content_view' => host.content_view.try(:label),
          'content_view_info' => content_view_info
        }

        if host.content_facet.present?
          info['parameters']['kickstart_repository'] = host.content_facet.kickstart_repository.try(:label)
        end
        info
      end

      def content_view_info
        return {} if host.content_view.blank?

        content_view_info = {
          'label' => host.content_view.try(:label),
          'latest-version' => host.content_view.try(:latest_version),
          'version' => content_version.try(:version),
          'published' => content_version.try(:created_at).try(:time).to_s,
          'components' => content_view_components
        }

        content_view_info
      end

      def content_view_components
        return {} unless host.content_view.try(:composite)

        components = {}
        content_version.try(:content_view_version_components).map do |cv|
          cv_label = cv.component_version.content_view.label
          components[cv_label] = {}
          components[cv_label]['version'] = cv.component_version.try(:version)
          components[cv_label]['published'] = cv.component_version.try(:created_at).try(:time).to_s
        end
        components
      end

      def content_version
        host.content_view.try(:version, host.lifecycle_environment)
      end
    end
  end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
katello-3.17.0.rc2.1 app/models/katello/host/info_provider.rb
katello-3.16.1.2 app/models/katello/host/info_provider.rb
katello-3.16.1.1 app/models/katello/host/info_provider.rb
katello-3.17.0.rc2 app/models/katello/host/info_provider.rb
katello-3.16.1 app/models/katello/host/info_provider.rb
katello-3.17.0.rc1 app/models/katello/host/info_provider.rb
katello-3.16.0 app/models/katello/host/info_provider.rb
katello-3.16.0.rc5.1 app/models/katello/host/info_provider.rb
katello-3.16.0.rc5 app/models/katello/host/info_provider.rb
katello-3.16.0.rc4.1 app/models/katello/host/info_provider.rb
katello-3.15.3.1 app/models/katello/host/info_provider.rb
katello-3.15.3 app/models/katello/host/info_provider.rb
katello-3.16.0.rc4 app/models/katello/host/info_provider.rb
katello-3.16.0.rc3.1 app/models/katello/host/info_provider.rb
katello-3.15.2 app/models/katello/host/info_provider.rb
katello-3.16.0.rc3 app/models/katello/host/info_provider.rb
katello-3.16.0.rc2.1 app/models/katello/host/info_provider.rb
katello-3.16.0.rc2 app/models/katello/host/info_provider.rb
katello-3.15.1.1 app/models/katello/host/info_provider.rb
katello-3.16.0.rc1.1 app/models/katello/host/info_provider.rb