Module: RedhatAccess::Concerns::HostManagedExtensions::ClassMethods

Defined in:
app/models/redhat_access/concerns/host_managed_extensions.rb

Instance Method Summary collapse

Instance Method Details

#search_by_plan_id(key, operator, value) ⇒ Object



12
13
14
15
16
17
18
19
# File 'app/models/redhat_access/concerns/host_managed_extensions.rb', line 12

def search_by_plan_id(key, operator, value)
  insights_plan_runner = ForemanAnsible::InsightsPlanRunner.new(Organization.current, value.to_i)
  hostname_rules_relation = insights_plan_runner.hostname_rules(insights_plan_runner.playbook)
  hosts = hostname_rules_relation.keys.map do |hostname|
    Host::Managed.find_by(:name => hostname).id
  end
  { :conditions => " hosts.id IN(#{hosts.join(',')})" }
end