Sha256: 452f2bef3556649522705d19de5eb16e0d6ea9af603310fa065efad0ca2b8288
Contents?: true
Size: 1.24 KB
Versions: 4
Compression:
Stored size: 1.24 KB
Contents
# # Copyright (c) 2014 Red Hat Inc. # # This software is licensed to you under the GNU General Public License, # version 3 (GPLv3). There is NO WARRANTY for this software, express or # implied, including the implied warranties of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv3 # along with this software; if not, see http://www.gnu.org/licenses/gpl.txt # module ForemanOpenscap::Helper def self.get_asset(cname, policy_id) asset = find_host_by_name_or_uuid(cname).get_asset asset.policy_ids += [policy_id] asset end def self.find_name_or_uuid_by_host(host) if defined?(::Katello::System) host.content_host.uuid else host.name end end private def self.find_host_by_name_or_uuid(cname) if defined?(Katello::System) host = Host.includes(:content_host).where(:katello_systems => {:uuid => cname}).first host ||= Host.find_by_name(cname) else host = Host.find_by_name(cname) end unless host Rails.logger.error "Could not find Host with name: #{cname}" Rails.logger.error "Please check that Content host is linked to Foreman host" if defined?(Katello::System) fail ActiveRecord::RecordNotFound end host end end
Version data entries
4 entries across 4 versions & 1 rubygems