Sha256: 667650472f4e2ef84538702e7832f745841586426893cf491b24032ece629374
Contents?: true
Size: 1.23 KB
Versions: 28
Compression:
Stored size: 1.23 KB
Contents
module ForemanOpenscap class PolicyMailer < ::ApplicationMailer def policy_summary(options = {}) set_url user = ::User.find(options[:user]) @time = options[:time] || 1.day.ago @policies = ::ForemanOpenscap::Policy.all.reject { |policy| policy.assets.map(&:host).compact.empty? } @compliant_hosts = @policies.map { |policy| Host.comply_with policy }.flatten @incompliant_hosts = @policies.map { |policy| Host.not_comply_with policy }.flatten changed_hosts_of_policies(@policies) if user.nil? || user.mail.nil? logger.warn "User with valid email not supplied, mail report will not be sent" else set_locale_for(user) do subject = _("SCAP policies summary") mail(:to => user.mail, :subject => subject) end end end private def changed_hosts_of_policies(policies) hash = @policies.inject({}) do |result, policy| result[policy.id] = policy.hosts result end @changed_hosts = [] hash.each do |key, values| values.each do |host| @changed_hosts << host if host.scap_status_changed?(::ForemanOpenscap::Policy.find(key)) end end @changed_hosts.uniq end end end
Version data entries
28 entries across 28 versions & 1 rubygems