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
24
25
26
27
28
29
30
|
# File 'app/services/foreman_openscap/lookup_key_overrider.rb', line 24
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[:base] << err
false
end
|
#handle_config_not_available(config) ⇒ Object
16
17
18
19
20
21
22
|
# File 'app/services/foreman_openscap/lookup_key_overrider.rb', line 16
def handle_config_not_available(config)
return true if config.available?
@policy.errors[: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
32
33
34
35
36
37
38
39
|
# File 'app/services/foreman_openscap/lookup_key_overrider.rb', line 32
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[:base] << err
false
end
|
#handle_param_override(config, param) ⇒ Object
53
54
55
56
57
58
59
60
61
|
# File 'app/services/foreman_openscap/lookup_key_overrider.rb', line 53
def handle_param_override(config, param)
if param.changed? && !param.save
@policy.errors[: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
49
50
51
|
# File 'app/services/foreman_openscap/lookup_key_overrider.rb', line 49
def handle_policies_param_override(config, param)
handle_param_override config, param
end
|
#handle_port_param_override(config, param) ⇒ Object
45
46
47
|
# File 'app/services/foreman_openscap/lookup_key_overrider.rb', line 45
def handle_port_param_override(config, param)
handle_param_override config, param
end
|
#handle_server_param_override(config, param) ⇒ Object
41
42
43
|
# File 'app/services/foreman_openscap/lookup_key_overrider.rb', line 41
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
|