Sha256: 2556190c1fcf1b30f2b50dd3e787d6c515704ced4f8d18795bd8d78feb945886

Contents?: true

Size: 1.79 KB

Versions: 30

Compression:

Stored size: 1.79 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),
          '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)
        end
        components
      end

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

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
katello-3.12.0 app/models/katello/host/info_provider.rb
katello-3.12.0.rc2 app/models/katello/host/info_provider.rb
katello-3.10.1.1 app/models/katello/host/info_provider.rb
katello-3.12.0.rc1 app/models/katello/host/info_provider.rb
katello-3.10.1 app/models/katello/host/info_provider.rb
katello-3.11.1 app/models/katello/host/info_provider.rb
katello-3.11.0 app/models/katello/host/info_provider.rb
katello-3.11.0.rc2 app/models/katello/host/info_provider.rb
katello-3.11.0.rc1 app/models/katello/host/info_provider.rb
katello-3.10.0 app/models/katello/host/info_provider.rb
katello-3.10.0.rc1.1 app/models/katello/host/info_provider.rb
katello-3.9.1 app/models/katello/host/info_provider.rb
katello-3.10.0.rc1 app/models/katello/host/info_provider.rb
katello-3.9.0 app/models/katello/host/info_provider.rb
katello-3.8.1 app/models/katello/host/info_provider.rb
katello-3.9.0.rc2 app/models/katello/host/info_provider.rb
katello-3.9.0.rc1 app/models/katello/host/info_provider.rb
katello-3.7.1.1 app/models/katello/host/info_provider.rb
katello-3.7.1 app/models/katello/host/info_provider.rb
katello-3.8.0 app/models/katello/host/info_provider.rb