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-10.0.3 lib/foreman_openscap/helper.rb
foreman_openscap-10.0.2 lib/foreman_openscap/helper.rb
foreman_openscap-10.0.1 lib/foreman_openscap/helper.rb
foreman_openscap-10.0.0 lib/foreman_openscap/helper.rb
foreman_openscap-9.0.4 lib/foreman_openscap/helper.rb
foreman_openscap-9.0.3 lib/foreman_openscap/helper.rb
foreman_openscap-9.0.2 lib/foreman_openscap/helper.rb
foreman_openscap-9.0.1 lib/foreman_openscap/helper.rb
foreman_openscap-9.0.0 lib/foreman_openscap/helper.rb
foreman_openscap-8.0.0 lib/foreman_openscap/helper.rb
foreman_openscap-7.1.1 lib/foreman_openscap/helper.rb
foreman_openscap-7.1.0 lib/foreman_openscap/helper.rb
foreman_openscap-7.0.0 lib/foreman_openscap/helper.rb
foreman_openscap-6.0.0 lib/foreman_openscap/helper.rb
foreman_openscap-5.2.3 lib/foreman_openscap/helper.rb
foreman_openscap-5.2.2 lib/foreman_openscap/helper.rb
foreman_openscap-5.1.1 lib/foreman_openscap/helper.rb
foreman_openscap-5.2.1 lib/foreman_openscap/helper.rb
foreman_openscap-5.2.0 lib/foreman_openscap/helper.rb
foreman_openscap-5.1.0 lib/foreman_openscap/helper.rb