Class: ForemanAnsibleDirector::Actions::ConsistencyCheck::Check::RoleRemotes

Inherits:
Base::AnsibleDirectorAction show all
Defined in:
app/lib/foreman_ansible_director/actions/consistency_check/check/role_remotes.rb

Instance Method Summary collapse

Methods inherited from Base::AnsibleDirectorAction

#humanized_name, #queue, #task_output

Instance Method Details

#plan(*_args) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/lib/foreman_ansible_director/actions/consistency_check/check/role_remotes.rb', line 15

def plan(*_args)
  all_referenced_role_remote_hrefs = Set.new
  all_referenced_role_remote_hrefs.merge(
    ::ForemanAnsibleDirector::ContentUnitVersion.unscoped.where(
      versionable_type: 'ForemanAnsibleDirector::AnsibleRole',
      source_type: 'galaxy'
    ).all.pluck(:pulp_remote_href)
  )

  role_remote_list_action = plan_action(
    ::ForemanAnsibleDirector::Actions::Pulp3::Ansible::Remote::Role::ListAll
  )
  plan_self(
    all_referenced_role_remote_hrefs: all_referenced_role_remote_hrefs.to_a,
    role_remote_list_action: role_remote_list_action.output
  )
end

#runObject



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/lib/foreman_ansible_director/actions/consistency_check/check/role_remotes.rb', line 33

def run
  all_referenced_role_remote_hrefs = Set.new(input[:all_referenced_role_remote_hrefs])
  all_pulp_role_remote_hrefs = input[:role_remote_list_action][:role_remote_list_response]

  unreferenced_role_remote_hrefs = []

  all_pulp_role_remote_hrefs.each do |role_remote|
    pulp_href = role_remote[:pulp_href]
    unreferenced_role_remote_hrefs << pulp_href unless all_referenced_role_remote_hrefs.include?(pulp_href)
  end

  output.update(unreferenced_role_remote_hrefs: unreferenced_role_remote_hrefs)
end