Module: Katello::Concerns::HostManagedExtensions::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

#find_by_installed_debs(_key, _operator, value) ⇒ Object



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'app/models/katello/concerns/host_managed_extensions.rb', line 238

def find_by_installed_debs(_key, _operator, value)
  name, architecture, version = Katello::Deb.split_nav(value)
  debs = Katello::InstalledDeb.where(:name => name)
  debs = debs.where(:architecture => architecture) unless architecture.nil?
  debs = debs.where(:version => version) unless version.nil?
  hosts = debs.joins(:host_installed_debs).select("#{Katello::HostInstalledDeb.table_name}.host_id as host_id").pluck(:host_id)
  if hosts.empty?
    {
      :conditions => "1=0",
    }
  else
    {
      :conditions => "#{::Host::Managed.table_name}.id IN (#{hosts.join(',')})",
    }
  end
end