Module: Katello::Concerns::SubscriptionFacetHostExtensions::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

#find_by_activation_key(_key, operator, value) ⇒ Object



74
75
76
77
78
# File 'app/models/katello/concerns/subscription_facet_host_extensions.rb', line 74

def find_by_activation_key(_key, operator, value)
  conditions = sanitize_sql_for_conditions(["#{Katello::ActivationKey.table_name}.name #{operator} ?", value_to_sql(operator, value)])
  hosts = ::Host::Managed.joins(:activation_keys).where(conditions)
  return_hosts(hosts)
end

#find_by_activation_key_id(_key, operator, value) ⇒ Object



80
81
82
83
84
# File 'app/models/katello/concerns/subscription_facet_host_extensions.rb', line 80

def find_by_activation_key_id(_key, operator, value)
  conditions = sanitize_sql_for_conditions(["#{Katello::ActivationKey.table_name}.id #{operator} ?", value_to_sql(operator, value)])
  hosts = ::Host::Managed.joins(:activation_keys).where(conditions)
  return_hosts(hosts)
end

#find_by_hypervisor_host(_key, operator, value) ⇒ Object



86
87
88
89
90
91
# File 'app/models/katello/concerns/subscription_facet_host_extensions.rb', line 86

def find_by_hypervisor_host(_key, operator, value)
  conditions = sanitize_sql_for_conditions(["#{::Host.table_name}.name #{operator} ?", value_to_sql(operator, value)])
  hosts = ::Host.where(conditions)
  hosts = ::Host.joins(:subscription_facet).where("#{Katello::Host::SubscriptionFacet.table_name}.hypervisor_host_id" => hosts)
  return_hosts(hosts)
end

#return_hosts(hosts) ⇒ Object



101
102
103
104
105
106
107
# File 'app/models/katello/concerns/subscription_facet_host_extensions.rb', line 101

def return_hosts(hosts)
  if hosts.empty?
    {:conditions => "1=0"}
  else
    {:conditions => "#{::Host::Managed.table_name}.id IN (#{hosts.pluck(:id).join(',')})"}
  end
end

#return_hosts_by_id(host_ids) ⇒ Object



93
94
95
96
97
98
99
# File 'app/models/katello/concerns/subscription_facet_host_extensions.rb', line 93

def return_hosts_by_id(host_ids)
  if host_ids.empty?
    {:conditions => "1=0"}
  else
    {:conditions => "#{::Host::Managed.table_name}.id IN (#{host_ids.to_sql})"}
  end
end

#rhel_lifecycle_status_mapObject



70
71
72
# File 'app/models/katello/concerns/subscription_facet_host_extensions.rb', line 70

def rhel_lifecycle_status_map
  ::Katello::RhelLifecycleStatus.status_map
end