3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'app/services/foreman_openscap/hostgroup_overrider_common.rb', line 3
def add_overrides(collection, host_or_hg, config)
model_match = host_or_hg.class.name.underscore =~ /\Ahostgroup\z/ ? "hostgroup" : "fqdn"
collection.where(:override => true).find_each do |override|
return unless host_or_hg.openscap_proxy && (url = host_or_hg.openscap_proxy.url).present?
openscap_proxy_uri = URI.parse(url)
case override.key
when config.server_param
lookup_value = LookupValue.where(:match => "#{model_match}=#{host_or_hg.to_label}", :lookup_key_id => override.id).first_or_initialize
lookup_value.update_attribute(:value, openscap_proxy_uri.host)
when config.port_param
lookup_value = LookupValue.where(:match => "#{model_match}=#{host_or_hg.to_label}", :lookup_key_id => override.id).first_or_initialize
lookup_value.update_attribute(:value, openscap_proxy_uri.port)
end
end
end
|