Sha256: 177eece78786ab7bbc8751a49e5190a02c074b3cd632e9847a29da2b808defe2

Contents?: true

Size: 717 Bytes

Versions: 37

Compression:

Stored size: 717 Bytes

Contents

module ForemanOpenscap::Helper
  def self.get_asset(cname, policy_id)
    asset = find_host_by_name_or_uuid(cname)&.get_asset
    return unless asset
    asset.policy_ids += [policy_id] unless asset.policy_ids.include?(policy_id)
    asset
  end

  def self.find_name_or_uuid_by_host(host)
    host.respond_to?(:subscription_facet) && !host.subscription_facet.nil? ? host.subscription_facet.try(:uuid) : host.name
  end

  def self.find_host_by_name_or_uuid(cname)
    if Facets.registered_facets.keys.include?(:subscription_facet)
      host = Katello::Host::SubscriptionFacet.find_by(uuid: cname).try(:host)
      host ||= Host.find_by(name: cname)
    else
      host = Host.find_by(name: cname)
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
foreman_openscap-5.0.0 lib/foreman_openscap/helper.rb
foreman_openscap-4.3.3 lib/foreman_openscap/helper.rb
foreman_openscap-4.3.2 lib/foreman_openscap/helper.rb
foreman_openscap-4.3.1 lib/foreman_openscap/helper.rb
foreman_openscap-4.3.0 lib/foreman_openscap/helper.rb
foreman_openscap-4.1.3 lib/foreman_openscap/helper.rb
foreman_openscap-4.0.6 lib/foreman_openscap/helper.rb
foreman_openscap-4.2.0 lib/foreman_openscap/helper.rb
foreman_openscap-4.0.5 lib/foreman_openscap/helper.rb
foreman_openscap-4.1.2 lib/foreman_openscap/helper.rb
foreman_openscap-4.1.1 lib/foreman_openscap/helper.rb
foreman_openscap-4.1.0 lib/foreman_openscap/helper.rb
foreman_openscap-4.0.4 lib/foreman_openscap/helper.rb
foreman_openscap-4.0.3 lib/foreman_openscap/helper.rb
foreman_openscap-4.0.2 lib/foreman_openscap/helper.rb
foreman_openscap-4.0.1 lib/foreman_openscap/helper.rb
foreman_openscap-3.0.1 lib/foreman_openscap/helper.rb