Module: ForemanOpenscap::OpenscapProxyCoreExtensions

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/foreman_openscap/openscap_proxy_core_extensions.rb

Instance Method Summary collapse

Instance Method Details

#update_client_params(model_match, config) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/concerns/foreman_openscap/openscap_proxy_core_extensions.rb', line 20

def update_client_params(model_match, config)
  client_item = config.find_config_item self.public_send(config.all_collection_method)
  return unless client_item
  lookup_keys = client_item.public_send(config.override_method_name)
  server_key = lookup_keys.find { |param| param.key == config.server_param }
  port_key = lookup_keys.find { |param| param.key == config.port_param }
  return if server_key.nil? || port_key.nil?
  pairs = scap_client_lookup_values_for([server_key, port_key], model_match)
  if openscap_proxy_id
    mapping = { config.server_param => openscap_proxy.hostname, config.port_param => openscap_proxy.port }
    update_scap_client_lookup_values(pairs, model_match, mapping)
  else
    destroy_scap_client_lookup_values pairs
  end
end

#update_scap_clientObject



10
11
12
13
14
15
16
17
18
# File 'app/models/concerns/foreman_openscap/openscap_proxy_core_extensions.rb', line 10

def update_scap_client
  name_service = ConfigNameService.new
  if openscap_proxy_id_previously_changed?
    model_match = self.class.name.underscore =~ /\Ahostgroup\z/ ? "hostgroup" : "fqdn"
    name_service.all_available_except(:manual).each do |config|
      update_client_params(model_match, config)
    end
  end
end