Module: ForemanOpenscap::Helper
- Defined in:
- lib/foreman_openscap/helper.rb
Class Method Summary collapse
- .find_host_by_name_or_uuid(cname) ⇒ Object
- .find_name_or_uuid_by_host(host) ⇒ Object
- .get_asset(cname, policy_id) ⇒ Object
Class Method Details
.find_host_by_name_or_uuid(cname) ⇒ Object
[View source]
13 14 15 16 17 18 19 20 |
# File 'lib/foreman_openscap/helper.rb', line 13 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 |
.find_name_or_uuid_by_host(host) ⇒ Object
[View source]
9 10 11 |
# File 'lib/foreman_openscap/helper.rb', line 9 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 |
.get_asset(cname, policy_id) ⇒ Object
[View source]
2 3 4 5 6 7 |
# File 'lib/foreman_openscap/helper.rb', line 2 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 |