Class: ForemanOpenscap::Oval::Configure
- Inherits:
-
Object
- Object
- ForemanOpenscap::Oval::Configure
- Includes:
- HostgroupOverriderCommon
- Defined in:
- app/services/foreman_openscap/oval/configure.rb
Instance Method Summary collapse
- #assign(oval_policy, ids, model_class) ⇒ Object
-
#initialize ⇒ Configure
constructor
A new instance of Configure.
Methods included from HostgroupOverriderCommon
#add_overrides, #remove_overrides
Constructor Details
#initialize ⇒ Configure
Returns a new instance of Configure.
6 7 8 |
# File 'app/services/foreman_openscap/oval/configure.rb', line 6 def initialize @config = ForemanOpenscap::ClientConfig::Ansible.new(::ForemanOpenscap::OvalPolicy) end |
Instance Method Details
#assign(oval_policy, ids, model_class) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/services/foreman_openscap/oval/configure.rb', line 10 def assign(oval_policy, ids, model_class) check_collection = ::ForemanOpenscap::Oval::Setup.new.run return check_collection unless check_collection.all_passed? ansible_role = @config.find_config_item if model_class == ::Hostgroup roles_method = :inherited_and_own_ansible_roles ids_setter = :hostgroup_ids= check_id = :hostgroups_without_proxy elsif model_class == ::Host::Managed roles_method = :all_ansible_roles ids_setter = :host_ids= check_id = :hosts_without_proxy else raise "Unexpected model_class, expected ::Hostgroup or ::Host::Managed, got: #{model_class}" end items_with_proxy, items_without_proxy = openscap_proxy_associated(ids, model_class) if items_without_proxy.any? return without_proxy_to_check items_without_proxy, check_id end oval_policy.send(ids_setter, items_with_proxy.pluck(:id)) unless oval_policy.save return check_collection.add_check model_to_check(oval_policy, :oval_policy_errors) end check_collection.merge modify_items(items_with_proxy, oval_policy, ansible_role, roles_method) end |