Class: ForemanOpenscap::LookupKeyOverrider
- Inherits:
-
Object
- Object
- ForemanOpenscap::LookupKeyOverrider
show all
- Includes:
- LookupKeyOverridesCommon
- Defined in:
- app/services/foreman_openscap/lookup_key_overrider.rb
Instance Method Summary
collapse
#missing_lookup_keys, #override_param, #override_params, #override_policies_param, #override_port_param, #override_required_params, #override_server_param
Constructor Details
Returns a new instance of LookupKeyOverrider.
5
6
7
8
|
# File 'app/services/foreman_openscap/lookup_key_overrider.rb', line 5
def initialize(policy)
@policy = policy
@name_service = ConfigNameService.new
end
|
Instance Method Details
#handle_config_item_not_available(config, item) ⇒ Object
25
26
27
28
29
30
31
|
# File 'app/services/foreman_openscap/lookup_key_overrider.rb', line 25
def handle_config_item_not_available(config, item)
return true if item
err = _("Required %{msg_name} %{class} was not found, please ensure it is imported first.") %
{ :class => config.config_item_name, :msg_name => config.msg_name }
@policy.errors.add(:base, err)
false
end
|
#handle_config_not_available(config) ⇒ Object
16
17
18
19
20
21
22
23
|
# File 'app/services/foreman_openscap/lookup_key_overrider.rb', line 16
def handle_config_not_available(config)
return true if config.available?
@policy.errors.add(:deploy_by,
_("%{type} was selected to deploy policy to clients, but %{type} is not available. Are you missing a plugin?") %
{ :type => config.type.to_s.camelize }
)
false
end
|
#handle_missing_lookup_keys(config, key_names) ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'app/services/foreman_openscap/lookup_key_overrider.rb', line 33
def handle_missing_lookup_keys(config, key_names)
return true if key_names.empty?
err = _("The following %{key_name} were missing for %{item_name}: %{key_names}. Make sure they are imported before proceeding.") %
{ :key_name => config.lookup_key_plural_name, :key_names => key_names, :item_name => config.config_item_name }
@policy.errors.add(:base, err)
false
end
|
#handle_param_override(config, param) ⇒ Object
54
55
56
57
58
59
60
61
62
|
# File 'app/services/foreman_openscap/lookup_key_overrider.rb', line 54
def handle_param_override(config, param)
if param.changed? && !param.save
@policy.errors.add(:base,
_('Failed to save when overriding parameters for %{config_tool}, cause: %{errors}') %
{ :config_tool => config.type, :errors => param.errors.full_messages.join(', ') })
return false
end
true
end
|
#handle_policies_param_override(config, param) ⇒ Object
50
51
52
|
# File 'app/services/foreman_openscap/lookup_key_overrider.rb', line 50
def handle_policies_param_override(config, param)
handle_param_override config, param
end
|
#handle_port_param_override(config, param) ⇒ Object
46
47
48
|
# File 'app/services/foreman_openscap/lookup_key_overrider.rb', line 46
def handle_port_param_override(config, param)
handle_param_override config, param
end
|
#handle_server_param_override(config, param) ⇒ Object
42
43
44
|
# File 'app/services/foreman_openscap/lookup_key_overrider.rb', line 42
def handle_server_param_override(config, param)
handle_param_override config, param
end
|
#override ⇒ Object
10
11
12
13
14
|
# File 'app/services/foreman_openscap/lookup_key_overrider.rb', line 10
def override
return unless @policy.deploy_by && Policy.deploy_by_variants.include?(@policy.deploy_by)
config = @name_service.config_for @policy.deploy_by.to_sym
super config
end
|